<commit_before>using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Data.Entity;
using Microsoft.Framework.Logging;
using Microsoft.Framework.Configuration;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Dnx.Runtime;
using Topicomb.Forum.Models;
using Topicomb.Forum.Exceptions;

namespace Topicomb.Forum
{
    public class Startup
    {
        public static IConfiguration Configuration { get; set; }
        
        public void ConfigureServices(IServiceCollection services)
        {  
            var _services = services.BuildServiceProvider();
            var appEnv = _services.GetRequiredService<IApplicationEnvironment>(); 
            var env = _services.GetRequiredService<IHostingEnvironment>();
            
            var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json")
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
            Configuration = builder.Build();
            
            switch(Configuration["Database:Mode"])
            {
                case "SQLite":
                    services.AddEntityFramework()
                        .AddSqlite()
                        .AddDbContext<ForumContext> (x => x.UseSqlite(Configuration["Database:ConnectionString"].Replace("{AppRoot}", appEnv.ApplicationBasePath)));
                    break;
                case "SQLServer":
                    services.AddEntityFramework()
                        .AddSqlServer()
                        .AddDbContext<ForumContext> (x => x.UseSqlServer(Configuration["Database:ConnectionString"].Replace("{AppRoot}", appEnv.ApplicationBasePath)));
                    break;
                case "InMemory":
                    services.AddEntityFramework()
                        .AddInMemoryDatabase()
                        .AddDbContext<ForumContext> (x => x.UseInMemoryDatabase());
                        break;
                default:
                    throw new DatabaseNotSupportedException(Configuration["Database:Mode"]);
            }
            
            services.AddIdentity<User, IdentityRole<long>>(x => 
            {
                x.Password.RequiredLength = Convert.ToInt32(Configuration["Password:RequiredLength"]);
                x.Password.RequireDigit = Convert.ToBoolean(Configuration["Password:RequireDigit"]);
                x.Password.RequireLowercase = Convert.ToBoolean(Configuration["Password:RequireLowercase"]);
                x.Password.RequireNonLetterOrDigit = Convert.ToBoolean(Configuration["Password:RequireNonLetterOrDigit"]);
                x.Password.RequireUppercase = Convert.ToBoolean(Configuration["Password:RequireUppercase"]);
                if (!Convert.ToBoolean(Configuration["Password:AllowedUserNameCharacters"]))
                    x.User.AllowedUserNameCharacters = null;
            })
                .AddEntityFrameworkStores<ForumContext, long>()
                .AddDefaultTokenProviders();
                
                
                
            services.AddMvc()
                .AddTemplate();
                
            services.AddCurrentUser<long, User>();
            services.AddCodeCombLocalizationJsonDictionary();
        }

        public async void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            app.UseIdentity();
            app.UseStaticFiles();
            
            app.UseMvc(router =>
            {
                router.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseCodeCombLocalization("/shared/localization.js");

            await SampleData.InitDB(app.ApplicationServices);
        }
    }
}<commit_msg>modify localization middleware<commit_after>using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Data.Entity;
using Microsoft.Framework.Logging;
using Microsoft.Framework.Configuration;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Dnx.Runtime;
using Topicomb.Forum.Models;
using Topicomb.Forum.Exceptions;

namespace Topicomb.Forum
{
    public class Startup
    {
        public static IConfiguration Configuration { get; set; }
        
        public void ConfigureServices(IServiceCollection services)
        {  
            var _services = services.BuildServiceProvider();
            var appEnv = _services.GetRequiredService<IApplicationEnvironment>(); 
            var env = _services.GetRequiredService<IHostingEnvironment>();
            
            var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json")
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
            Configuration = builder.Build();
            
            switch(Configuration["Database:Mode"])
            {
                case "SQLite":
                    services.AddEntityFramework()
                        .AddSqlite()
                        .AddDbContext<ForumContext> (x => x.UseSqlite(Configuration["Database:ConnectionString"].Replace("{AppRoot}", appEnv.ApplicationBasePath)));
                    break;
                case "SQLServer":
                    services.AddEntityFramework()
                        .AddSqlServer()
                        .AddDbContext<ForumContext> (x => x.UseSqlServer(Configuration["Database:ConnectionString"].Replace("{AppRoot}", appEnv.ApplicationBasePath)));
                    break;
                case "InMemory":
                    services.AddEntityFramework()
                        .AddInMemoryDatabase()
                        .AddDbContext<ForumContext> (x => x.UseInMemoryDatabase());
                        break;
                default:
                    throw new DatabaseNotSupportedException(Configuration["Database:Mode"]);
            }
            
            services.AddIdentity<User, IdentityRole<long>>(x => 
            {
                x.Password.RequiredLength = Convert.ToInt32(Configuration["Password:RequiredLength"]);
                x.Password.RequireDigit = Convert.ToBoolean(Configuration["Password:RequireDigit"]);
                x.Password.RequireLowercase = Convert.ToBoolean(Configuration["Password:RequireLowercase"]);
                x.Password.RequireNonLetterOrDigit = Convert.ToBoolean(Configuration["Password:RequireNonLetterOrDigit"]);
                x.Password.RequireUppercase = Convert.ToBoolean(Configuration["Password:RequireUppercase"]);
                if (!Convert.ToBoolean(Configuration["Password:AllowedUserNameCharacters"]))
                    x.User.AllowedUserNameCharacters = null;
            })
                .AddEntityFrameworkStores<ForumContext, long>()
                .AddDefaultTokenProviders();
                
            services.AddMvc()
                .AddTemplate();
                
            services.AddCurrentUser<long, User>();
            services.AddCodeCombLocalizationJsonDictionary();
        }

        public async void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            app.UseIdentity();
            app.UseStaticFiles();
            
            app.UseMvc(router =>
            {
                router.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseCodeCombLocalization("/assets/shared/localization.js");

            await SampleData.InitDB(app.ApplicationServices);
        }
    }
}
{'fraction_non_alphanumeric': 0.09694858241230178, 'fraction_numerical': 0.0004805382027871216, 'mean_word_length': 2.067428150331614, 'pattern_counts': {'":': 6, '<': 21, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3491317', 'n_tokens_mistral': 1950, 'n_tokens_neox': 1891, 'n_words': 288}