コード例 #1
0
 public void BeforeScenario()
 {
     // "You should avoid using DI in unit testing" - from: http://stackoverflow.com/a/11093830/177710
     // That's why there's no Autofac here.
     _context.DatabaseContext = new DatabaseContext(CreateNewDatabase());
     _fakeEmailService        = new FakeEmailService(_context.DatabaseContext);
     AutoMapperBootstrap.Initialize();
 }
コード例 #2
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     AutofacConfig.RegisterDependencies();
     WebApiConfig.Register(GlobalConfiguration.Configuration);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     AuthConfig.RegisterAuth();
     AutoMapperBootstrap.Initialize();
 }
コード例 #3
0
 public void LoadDependencies()
 {
     _serviceCollection.AddTransient <IObjectMapper, AutoMapperObjectMapper>();
     _serviceCollection.AddSingleton(AutoMapperBootstrap.GetConfiguration());
 }
コード例 #4
0
 /// <summary>
 /// 添加AutoMapper注入支持
 /// </summary>
 /// <param name="services">服务容器</param>
 /// <param name="searchPattern">程序集匹配范围</param>
 /// <returns></returns>
 public static void AddAutoMapper(this IServiceCollection services, string searchPattern)
 {
     services.AddSingleton(c => Mapper.Instance);
     AutoMapperBootstrap.Initialize(searchPattern);
 }
コード例 #5
0
 protected void Application_Start(object sender, EventArgs e)
 {
     AutoMapperBootstrap.InitializeMap();
 }