42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System;
|
|
using System.Web;
|
|
using GeneralApi.Core.Infrastructure.IoC;
|
|
using Taloyhtio.GeneralApi.Core.Infrastructure.AutoMapper;
|
|
|
|
namespace Taloyhtio.GeneralApi.Core.Infrastructure.Web
|
|
{
|
|
public class AutoMapperConfigurationModule : IHttpModule
|
|
{
|
|
private static bool configured;
|
|
private static readonly object lockObject = new object();
|
|
|
|
public void Init(HttpApplication context)
|
|
{
|
|
context.BeginRequest += context_BeginRequest;
|
|
}
|
|
|
|
public void Dispose() { }
|
|
|
|
private static void context_BeginRequest(object sender, EventArgs e)
|
|
{
|
|
ensureConfigured();
|
|
}
|
|
|
|
private static void ensureConfigured()
|
|
{
|
|
// configuration is required only once per AppDomain
|
|
if (!configured)
|
|
{
|
|
lock (lockObject)
|
|
{
|
|
if (!configured)
|
|
{
|
|
AutoMapperConfiguration.Configure();
|
|
configured = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|