Пример #1
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     IOCConfig.Configure();
 }
Пример #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            services.AddDistributedMemoryCache();

            services.AddSession(options =>
            {
                options.IdleTimeout        = TimeSpan.FromHours(24);
                options.Cookie.HttpOnly    = true;
                options.Cookie.IsEssential = true;
                options.Cookie.Name        = "QLSuaxe";
                services.AddHttpContextAccessor();
                services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            });
            services.AddDbContext <APPDbContext>(options =>
                                                 options.UseSqlServer(Configuration.GetConnectionString("connectionString"),
                                                                      sqlServerOptionsAction: sqlOptions =>
            {
                sqlOptions.EnableRetryOnFailure(
                    maxRetryCount: 1000,
                    maxRetryDelay: TimeSpan.FromSeconds(30),
                    errorNumbersToAdd: null)
                .CommandTimeout(30).UseRowNumberForPaging();
            }), ServiceLifetime.Transient);
            services.AddControllers();
            IOCConfig.Register(services, Configuration);
        }
Пример #3
0
 protected void Application_Start()
 {
     IOCConfig.Configure();
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
Пример #4
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            //自动更新migration
            Database.SetInitializer(new MigrateDatabaseToLatestVersion <EFDBContext, Configuration>());

            IOCConfig.RegisterAutofac();
        }
Пример #5
0
        public static void RegisterComponents(HttpConfiguration config)
        {
            var container = new UnityContainer();

            // register all your components with the container here
            // it is NOT necessary to register your controllers

            // e.g. container.RegisterType<ITestService, TestService>();
            container.RegisterType <IUserService, UserService>();
            container.RegisterType <ITaskService, TaskService>();
            container.RegisterType <IProjectService, ProjectService>();
            container.RegisterType <ITaskGroupService, TaskGroupService>();
            IOCConfig.RegisterComponents(container);

            config.DependencyResolver = new UnityDependencyResolver(container);
        }
Пример #6
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
     services.AddDbContext <DoAnDbContext>(options =>
                                           options.UseSqlServer(Configuration.GetConnectionString("connectionString"),
                                                                sqlServerOptionsAction: sqlOptions =>
     {
         sqlOptions.EnableRetryOnFailure(
             maxRetryCount: 1000,
             maxRetryDelay: TimeSpan.FromSeconds(30),
             errorNumbersToAdd: null)
         .CommandTimeout(30).UseRowNumberForPaging();
     }), ServiceLifetime.Transient);
     services.AddControllers();
     services.AddMemoryCache();
     IOCConfig.Register(services, Configuration);
 }
Пример #7
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            ///
            ConfigureAutoMapper.Execute();
            ConfigureSchema.Execute();

            //Set IOC config
            var container = IOCConfig.InitializeClient(webAssembly: typeof(MTFS.Host.MVC.WebApiApplication).Assembly);

            GlobalConfiguration.Configuration.DependencyResolver =
                new AutofacWebApiDependencyResolver(container);

            GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
        }