コード例 #1
0
ファイル: Global.asax.cs プロジェクト: whitepawn23/LuzDary
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     AutofacInitializer.Initialize();
 }
コード例 #2
0
        private void SetupContainer()
        {
            var container = new ContainerBuilder();

            AutofacInitializer.Initialize(container, Settings.Default);

            Container = container.Build();
        }
コード例 #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            AutofacInitializer.Initialize(
                typeof(DSSEntities).Assembly,
                typeof(DSSEntities),
                new MapperConfiguration(this.AutoMapperConfig));
        }
コード例 #4
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
            AutofacInitializer.Initialize(config);
        }
コード例 #5
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var dbType   = typeof(OcmsEntities);
            var assembly = dbType.Assembly;

            AutofacInitializer.Initialize(
                assembly,
                dbType);
        }
コード例 #6
0
        public static void Entry(Action <IMapperConfigurationExpression> additionalMapperConfig, params Autofac.Module[] additionalModules)
        {
            Action <IMapperConfigurationExpression> fullMapperConfig = q =>
            {
                ApiEndpoint.ConfigAutoMapper(q);

                if (additionalMapperConfig != null)
                {
                    additionalMapperConfig(q);
                }
            };

            AutofacInitializer.Initialize(
                Assembly.GetExecutingAssembly(),
                typeof(DataEntities),
                new MapperConfiguration(fullMapperConfig),
                additionalModules);
        }
コード例 #7
0
        protected void Application_Start()
        {
            //custom route
            RouteTable.Routes.MapMvcAttributeRoutes();

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            AutofacInitializer.Initialize(
                System.Reflection.Assembly.GetExecutingAssembly(),
                typeof(SSNEntities),

                // AutoMapper config
                new MapperConfiguration(this.MapperConfig),

                // Autofac Modules
                new FileUploaderModule());
        }
コード例 #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            this.ConfigureOptions(services);

            services.AddEntityFramework(this.Configuration);

            services.AddCors();

            services.AddMvc(config =>
            {
                // Require authenticated user to access any controller action by default.
                // Anonymous access must be declared explicitly on controller method.
                var policy = new AuthorizationPolicyBuilder()
                             .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
                             .RequireAuthenticatedUser()
                             .Build();

                config.Filters.Add(new AuthorizeFilter(policy));
                config.RespectBrowserAcceptHeader = true;
            });

            services.AddAutoMapper();

            services.AddSwaggerGen(config =>
            {
                config.SwaggerDoc("v1", new Info
                {
                    Title   = "Jogging Tracker API",
                    Version = "v1"
                });

                var applicationPath = PlatformServices.Default.Application.ApplicationBasePath;
                config.IncludeXmlComments(Path.Combine(applicationPath, "WebApi.xml"));
            });

            services.AddMediatR(typeof(ValidatorBehavior <,>).GetTypeInfo().Assembly);

            return(AutofacInitializer.Initialize(services));
        }
コード例 #9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            string connection        = Configuration.GetConnectionString("DefaultConnection");
            string dbContextAssembly = typeof(ApplicationDbContext).GetTypeInfo().Assembly.GetName().Name;

            services.AddDbContext <ApplicationDbContext>(
                options => options.UseSqlServer(connection, x => x.MigrationsAssembly(dbContextAssembly)));

            services.AddAuthentication(options => options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme);

            services.AddIdentity <ApplicationUser, ApplicationRole>(options =>
            {
                options.Lockout.AllowedForNewUsers      = true;
                options.Lockout.MaxFailedAccessAttempts = 10;
                options.SignIn.RequireConfirmedEmail    = true;
                options.User.RequireUniqueEmail         = true;
                options.Password = new PasswordOptions
                {
                    RequireDigit           = false,
                    RequireLowercase       = false,
                    RequireNonAlphanumeric = false,
                    RequireUppercase       = false
                };
            })
            .AddEntityFrameworkStores <ApplicationDbContext, long>()
            .AddDefaultTokenProviders();

            services.AddOptions();

            services.AddMemoryCache();

            services.AddMvc();
            services.AddTransient <IEmailSender, AuthMessageSender>();
            services.AddTransient <ISmsSender, AuthMessageSender>();

            return(AutofacInitializer.Initialize(services, ApplicationContainer));
        }
コード例 #10
0
        private void InitializeIoc()
        {
            var autofacInitializer = new AutofacInitializer();

            autofacInitializer.Initialize();
        }