Example #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            DapperConfiguration.Configure();

            IDatabaseConfig dbConfig = this.Configuration.GetSection("DatabaseConfig").Get <DatabaseConfiguration>();

            services.AddSingleton(dbConfig);


            services.AddControllersWithViews()
#if DEBUG
            .AddRazorRuntimeCompilation()
#endif
            .AddJsonOptions(options =>
            {
                options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
                options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
            });

            if (dbConfig.InMemoryMode)
            {
                services.AddMemoryDatabaseModeServices();
            }
            else
            {
                services.AddMySqlDatabaseModeServices();
            }

            services.AddRealtimeServices();
            services.AddSignalR();
        }