Beispiel #1
0
        static void Main(string[] args)
        {
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json", false)
                                .Build();
            ConfigurationRoot configurationRoot = (ConfigurationRoot)configuration;
            var configurationProvider           = configurationRoot.Providers.Where(p => p.GetType() == typeof(JsonConfigurationProvider))
                                                  .FirstOrDefault(p => ((JsonConfigurationProvider)p).Source.Path == "appsettings.json");

            ConfigSetting.Init(configurationProvider);

            ServiceCollection serviceCollection = new ServiceCollection();

            ConfigureServices(serviceCollection);

            // create service provider
            var serviceProvider = serviceCollection.BuildServiceProvider();

            // entry to run app
            serviceProvider.GetService <App>().Run(serviceProvider).Wait();

            Console.WriteLine("App Start");
            var t = Console.ReadLine();
        }
Beispiel #2
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
            ConfigurationRoot configurationRoot = (ConfigurationRoot)configuration;
            var configurationProvider           = configurationRoot.Providers.Where(p => p.GetType() == typeof(JsonConfigurationProvider))
                                                  .FirstOrDefault(p => ((JsonConfigurationProvider)p).Source.Path == "appsettings.json");

            ConfigSetting.Init(configurationProvider);
        }
Beispiel #3
0
        private void LoadConfig()
        {
            ConfigurationRoot configurationRoot = (ConfigurationRoot)Configuration;
            IEnumerable <Microsoft.Extensions.Configuration.IConfigurationProvider> configurationProviders = configurationRoot
                                                                                                             .Providers
                                                                                                             .Where(p => p.GetType() == typeof(JsonConfigurationProvider) &&
                                                                                                                    ((JsonConfigurationProvider)p).Source.Path.StartsWith("appsettings"));

            foreach (Microsoft.Extensions.Configuration.IConfigurationProvider item in configurationProviders)
            {
                ConfigSetting.Init <ConfigSettingDefine>(item);
                ConfigSetting.Init <RedisConnectionConfig>(item);
            }
        }