private static void BootStrap() { AutoMapperConfiguration.Configure(typeof(SearchContactDtoToSearchContactFilterProfile).Assembly); Database.SetInitializer(new PhoneBookDbContextSeedInitializer()); var unitOfWorkFactory = new EntityFrameworkUnitOfWorkFactory(new PhoneBookDbContext()); var mapper = new AutoMapperMapping(); var validationFactory = new ValidationFactory(); validationFactory.Register(new SearchContactFilterValidator()); _contactCrudService = new ContactCrudService(unitOfWorkFactory, mapper, validationFactory); }
/// <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); }
protected void Application_Start() { Container = new Container(); Container.Configure(x => { x.Scan(y => { y.TheCallingAssembly(); y.AddAllTypesOf <ApiController>(); }); }); AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); GlobalConfiguration.Configuration.EnsureInitialized(); ObjectFactory.Initialize(x => { x.AddRegistry <RepositoryRegistry>(); }); HttpConfiguration config = GlobalConfiguration.Configuration; config.Services .Replace(typeof(IHttpControllerActivator), new ServiceActivator(config)); Database.SetInitializer <DoorContext>(new DoorTrackerContextInitializer()); using (var context = new DoorContext()) { context.Database.Initialize(force: true); } AutoMapperMapping.Config(); }
protected override void InitAutoMapper() { AutoMapperMapping.Init(); }
public void Configure() { AutoMapperMapping.Configure(); }
public DalConfigurator() { AutoMapperMapping.Configure(); }
public void Setup() { Mapper.Reset(); AutoMapperMapping.Configure(); }
protected override void OnApplicationStarted(object sender, EventArgs e) { AutoMapperMapping.CreateMaps(); }