Exemplo n.º 1
0
 public Startup(IConfiguration configuration, IWebHostEnvironment env)
 {
     Configuration = configuration;
     ConfigurationHelper.Configure(configuration);
     GlobalContext.LogWhenStart(env);
     GlobalContext.HostingEnvironment = env;
 }
Exemplo n.º 2
0
        protected void BindSettings(
            [NotNull] Type type,
            [NotNull] IConfigurationSection parent,
            [NotNull] IServiceCollection collection)
        {
            Ensure.Any.IsNotNull(type, nameof(type));
            Ensure.Any.IsNotNull(parent, nameof(parent));
            Ensure.Any.IsNotNull(collection, nameof(collection));

            var key = FindKey(type);

            if (key == null)
            {
                return;
            }

            var section = parent.GetSection(key);

            ConfigurationHelper.Configure(collection, section, type);

            GetMembers(type)
            .Where(m => m.Item2.GetCustomAttribute <SettingsAttribute>() != null)
            .Select(m => m.Item2)
            .ToList()
            .ForEach(t => BindSettings(t, section, collection));
        }
Exemplo n.º 3
0
        public void ConfigureShouldConfigureOptions()
        {
            var mockSettings = new MockSettings();

            var dict = new Dictionary <string, string>
            {
                { "Key", "Value" }
            };

            var configuration = new ConfigurationBuilder()
                                .AddInMemoryCollection(dict)
                                .Build();

            ConfigurationHelper.Configure(mockSettings, configuration);

            Assert.Equal("Value", mockSettings.Key);
        }
Exemplo n.º 4
0
        protected void BindSettings(
            Type type,
            IConfigurationSection parent,
            IServiceCollection collection)
        {
            Ensure.That(parent, nameof(parent)).IsNotNull();

            FindKey(type).Select(parent.GetSection).Iter(section =>
            {
                ConfigurationHelper.Configure(collection, section, type);

                GetMembers(type)
                .Select(t => (member: t.Item1, type: t.Item2))
                .Where(m => m.type.GetCustomAttribute <SettingsAttribute>() != null)
                .Select(m => m.type)
                .Iter(t => BindSettings(t, section, collection));
            });
        }
        public void Configure(EntityTypeBuilder <ApplicationLog> builder)
        {
            builder.ToTable("ss_tb_application_log");
            builder.HasKey(t => t.Id);

            builder.Property(t => t.Id)
            .HasColumnName("id");

            builder.Property(t => t.Message)
            .HasColumnName("message");

            builder.Property(t => t.LogTime)
            .HasColumnName("log_time");

            builder.Property(t => t.Description)
            .HasColumnName("description");

            ConfigurationHelper.Configure(builder);
        }
Exemplo n.º 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigurationHelper.Configure(Configuration);
            services.AddControllersWithViews();
            //添加认证Cookie信息

            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.LoginPath        = new PathString("/Home/Login");
                options.AccessDeniedPath = new PathString("/Home/CusError");
            });
            services.AddMvc().AddNewtonsoftJson().AddJsonOptions(options =>
            {
                options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
                options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
                options.JsonSerializerOptions.PropertyNamingPolicy        = JsonNamingPolicy.CamelCase;
            });

            RegisterServices(services);
        }
Exemplo n.º 7
0
 public Startup(IConfiguration configuration)
 {
     Configuration = configuration;
     ConfigurationHelper.Configure(Configuration);
 }