コード例 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            services = ServicesDependencyMapper.GetDependencies(services, Configuration);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: bogdantanasuca/EventApp
        static void Main(string[] args)
        {
            var services = ServicesDependencyMapper.GetDependencies(GetConfiguration()).BuildServiceProvider();

            using (var scope = services.CreateScope())
            {
                var eventService    = scope.ServiceProvider.GetService <IEventService>();
                var locationService = scope.ServiceProvider.GetService <ILocationService>();

                //locationService.DeleteLocationById(1110);
                foreach (var item in eventService.GetEvents())
                {
                    System.Console.WriteLine(item.Name);
                }

                //foreach (var item in locationService.GetLocations())
                //{
                //    System.Console.WriteLine(item.Name);
                //}
            }
        }
コード例 #3
0
ファイル: Startup.cs プロジェクト: macoveirares/prEvent
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddIdentityCore <UserDTO>(options => { });
            services = ServicesDependencyMapper.GetDependencies(services, Configuration);
            services.AddAuthentication("cookies").AddCookie("cookies", options => options.LoginPath = "/Account/SignIn");
            services.AddAuthorization(options =>
            {
                options.AddPolicy("AdminOnly", policy => policy.RequireClaim("HasAdminRights"));
            });

            services.AddSignalR();
        }