예제 #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
            .RegisterServiceBroker <ServiceBroker>(options =>
            {
                options.RegisterAutoMappingProviders   = true;
                options.RegisterCacheProviders         = true;
                options.RegisterMessagePackSerialisers = true;
                options.RegisterMediatorServices       = true;
                options.RegisterExceptionHandlers      = true;
                options.RegisterCryptographicProviders = true;
            }, out var serviceBroker);

            ServiceBroker.ConfigureIdentity(services
                                            .AddIdentity <Domains.Dto.Account, Role>());

            services
            .ConfigureApplicationCookie(ConfigureOptions)
            .ConfigureExternalCookie(ConfigureOptions);

            services
            .AddDistributedMemoryCache()
            .AddSession(ConfigureSession)
            .AddAuthentication();
            services
            .AddAuthorization();

            //;

            services
            .AddMvc(options => options.Filters.Add(new AuthorizeFilter(Policies.Build())))
            .AddSessionStateTempDataProvider()
            .AddFluentValidation(configuration => configuration
                                 .RegisterValidatorsFromAssemblies(serviceBroker.Assemblies));
        }