// 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 IServiceProvider ConfigureServices(IServiceCollection services)
        {
            /*
             * options =>
             * {
             *  options.DataAnnotationLocalizerProvider = (type, factory) =>
             *      factory.Create(typeof(SharedResource));
             * }
             */
            services.AddLocalization(
                setupAction =>
            {
                setupAction.ResourcesPath = "Resources";
            });

            services.AddMvc().AddViewLocalization(
                setupAction =>
            {
                setupAction.ResourcesPath = "Resources";
            })
            .AddDataAnnotationsLocalization(

                //options =>
                //    {
                //        options.DataAnnotationLocalizerProvider = (type, factory) =>
                //            factory.Create(typeof(SharedResource));
                //    }



                );

            services.Configure <AppMenuComponent>(_configuration.GetSection("Menu"));
            services.Configure <SqlConnectionConfig>(_configuration.GetSection("ConnectionStrings"));
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(
                options =>
            {
                options.Cookie.Name      = "MusicStoreApp";
                options.LoginPath        = "/Home/Login";
                options.AccessDeniedPath = "/Home/Denied";
                options.ExpireTimeSpan   = new TimeSpan(0, 0, 60);
            }
                );
            return(AutoFacContainer.GetServiceProvider(services));
        }
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            var authPolicy = new AuthorizationPolicyBuilder(JwtBearerDefaults.AuthenticationScheme)
                             .RequireAuthenticatedUser()
                             .Build();

            JwtBearerAuth.AddAuthentication(services, this.Configuration);
            services.AddClaimPolicies(this.Configuration);
            services.AddMvc(c =>
            {
                c.Filters.Add(new AuthorizeFilter(authPolicy));
                c.Filters.Add(new RequireHttpsAttribute());
            }).AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix, options => { options.ResourcesPath = "Resources"; })
            .AddDataAnnotationsLocalization();

            // services.AddMvc();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc(
                    "v1",
                    new Info
                {
                    Version        = "v1",
                    Title          = "Migration Solution",
                    Description    = "My First ASP.NET Core Web API",
                    TermsOfService = "None",
                    Contact        = new Contact()
                    {
                        Name  = "Migration Solution",
                        Email = "*****@*****.**",
                        Url   = "www.x.com"
                    }
                });
                c.AddSecurityDefinition(
                    "Bearer",
                    new ApiKeyScheme
                {
                    In          = "header",
                    Description = "Please enter JWT with Bearer into field",
                    Name        = "Authorization",
                    Type        = "apiKey"
                });
                c.AddSecurityRequirement(
                    new Dictionary <string, IEnumerable <string> > {
                    { "Bearer", Enumerable.Empty <string>() },
                });
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });

            services.AddHsts(c => { c.IncludeSubDomains = true; });
            services.AddHttpsRedirection(c =>
            {
                c.RedirectStatusCode = 301;
                if (this.Environment.IsDevelopment())
                {
                    c.HttpsPort = 44314;
                }
            });
            services.AddLocalization(options => { options.ResourcesPath = "Resources"; });
            services.Configure <SwaggerConfig>(Configuration.GetSection("Swagger"));
            services.Configure <DbConString>(Configuration.GetSection("ConnectionStrings"));

            FluentMapper.Initialize(config =>
            {
                config.AddMap(new UserInfoMap());
            });

            #region Dependency Module Injection and builder binding
            return(AutoFacContainer.GetServiceProvider(services));

            #endregion
        }