/// <summary>
        /// OWIN Configuration
        /// </summary>
        /// <param name="app"></param>
        public void Configuration(IAppBuilder app)
        {
            // Initialize IoC (see Dependency injection pattern https://en.wikipedia.org/wiki/Dependency_injection)
            if (UnitTests)
            {
                UnityResolver.UnitTestInitialize();
            }
            else
            {
                UnityResolver.Initialize();
            }

            var configuration = new HttpConfiguration {
                DependencyResolver = new UnityResolver()
            };



            // Attributes routing
            configuration.MapHttpAttributeRoutes();

            // Convention-based routing is not used as it is usually a good idea to use Attribute routing
            // See http://www.asp.net/Web-api/overview/Web-api-routing-and-actions/attribute-routing-in-Web-api-2#why
            // Uncomment following lines to enable Convention-based routing
            //config.Routes.MapHttpRoute(
            //    name: "DefaultApi",
            //    routeTemplate: "api/{controller}/{Id}",
            //    defaults: new { Id = RouteParameter.Optional }
            //);


            ConfigureAuth(app, configuration);
            ConfigureJsonSerializer(configuration);

            // Enable swagger docs
            // See https://github.com/domaindrivendev/Swashbuckle for details
            configuration
            .EnableSwagger("swagger/{apiVersion}/docs", (c) =>
            {
                c.SingleApiVersion(BaseController.Version, "WebAPI Toolkit");
                c.IncludeXmlComments(GetXmlCommentsPath());
            })
            .EnableSwaggerUi();

            // Init Automapper mappings
            AutoMapperMapping.Configure();

            // Attach Exception Handlers
            configuration.Filters.Add(new GlobalExceptionFilter());
            configuration.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler());

            app.UseWebApi(configuration);
        }
Exemple #2
0
 public void Configure()
 {
     AutoMapperMapping.Configure();
 }
 public DalConfigurator()
 {
     AutoMapperMapping.Configure();
 }
Exemple #4
0
 public void Setup()
 {
     Mapper.Reset();
     AutoMapperMapping.Configure();
 }