Beispiel #1
0
        public override IList <Setting> GetAllSettings()
        {
            string directory             = new WebAppTypeFinder().GetBinDirectory();
            var    configurationBasePath = directory.Substring(0, directory.IndexOf("\\Tests\\Grand.Services.Tests\\") + 27);

            var configuration = new ConfigurationBuilder()
                                .SetBasePath(configurationBasePath)
                                .AddJsonFile("appsettingstest.json", optional: false, reloadOnChange: true)
                                .Build();

            var settings      = new List <Setting>();
            var settingObject = new ServiceCollection().ConfigureStartupConfig <ApplicationSettings>(configuration.GetSection("ApplicationSettingsSection"));
            var properties    = settingObject.GetType().GetProperties();

            foreach (var property in properties)
            {
                var value = settingObject.GetType().GetProperty(property.Name).GetValue(settingObject, null);
                settings.Add(new Setting
                {
                    Name    = property.Name.ToLowerInvariant(),
                    Value   = value.ToString(),
                    StoreId = ""
                });
            }

            return(settings);
        }