Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <ApplicationConfiguration>(Configuration.GetSection("Application"));

            services.Configure <IISServerOptions>(options =>
            {
                options.AutomaticAuthentication = false;
            });

            services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("AppDbConnection")));
            services.AddIdentity <ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores <ApplicationDbContext>().AddDefaultTokenProviders();

            //services.AddAuthentication()
            //    .AddFacebook(facebookOptions =>
            //    {
            //        facebookOptions.AppId = Configuration["Authentication:Facebook:AppId"];
            //        facebookOptions.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
            //    });
            //    //.AddGoogle(googleOptions =>
            //{

            //})
            //.AddMicrosoftAccount(microsoftOptions =>
            //{
            //    microsoftOptions.ClientId = Configuration["Authentication:Microsoft:ClientId"];
            //    microsoftOptions.ClientSecret = Configuration["Authentication:Microsoft:ClientSecret"];
            //});

            IdentityOptionsConfiguration.IdentityOptions(services);

            services.ConfigureApplicationCookie(x =>
            {
                x.LoginPath        = Configuration.GetSection("Application:LoginPath").Value;
                x.AccessDeniedPath = Configuration.GetSection("Application:AccessDeniedPath").Value;
            });

            services.AddAutoMapper(typeof(Startup));
            services.AddControllersWithViews();
            services.AddRazorPages().AddRazorRuntimeCompilation();

            DependecyResolver.Resolve(services);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            serviceProvider = DependecyResolver.RegisterServices();
            inputParser     = serviceProvider.GetService <IInputParser>();

            try
            {
                Start();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            serviceProvider.DisposeServices();
        }
Ejemplo n.º 3
0
        public void Configuration(IAppBuilder app)
        {
            var builder = DependecyResolver.ServicesModule();

            var assembly = Assembly.GetExecutingAssembly();

            builder.RegisterApiControllers(assembly);

            var container = builder.Build();

            app.UseAutofacMiddleware(container);


            var config   = new HttpConf();
            var resolver = new AutofacWebApiDependencyResolver(container);

            config.DependencyResolver = resolver;

            app.UseAutofacWebApi(config);
            app.UseWebApi(config);
        }