示例#1
0
        public static Settings GetInstance()
        {
            var settings =
                ConfigurationManager.GetSection("kekiriSettings") as ConfigFileBasedSettings ??
                ConfigFileBasedSettings.GetInstanceWithDefaultValues();

            return(new Settings(settings));
        }
示例#2
0
        public static ConfigFileBasedSettings GetInstanceWithDefaultValues()
        {
            var settings = new ConfigFileBasedSettings();

            foreach (var propertyInfo in typeof(ConfigFileBasedSettings).GetProperties())
            {
                var attribute = (ConfigurationPropertyAttribute)
                                propertyInfo
                                .GetCustomAttributes(typeof(ConfigurationPropertyAttribute), false)
                                .SingleOrDefault();
                if (attribute != null && propertyInfo.CanWrite)
                {
                    propertyInfo.SetValue(settings, attribute.DefaultValue, null);
                }
            }

            return(settings);
        }
示例#3
0
        public static Settings GetInstance()
        {
            var settings = new ConfigFileBasedSettings();

            return(new Settings(settings));
        }
示例#4
0
 private Settings(ConfigFileBasedSettings settings)
 {
     _settings = settings;
 }
示例#5
0
文件: Settings.cs 项目: kcamp/Kekiri
        public static ConfigFileBasedSettings GetInstanceWithDefaultValues()
        {
            var settings = new ConfigFileBasedSettings();

            foreach (var propertyInfo in typeof(ConfigFileBasedSettings).GetProperties())
            {
                var attribute = (ConfigurationPropertyAttribute)
                                propertyInfo
                                    .GetCustomAttributes(typeof(ConfigurationPropertyAttribute), false)
                                    .SingleOrDefault();
                if (attribute != null && propertyInfo.CanWrite)
                {
                    propertyInfo.SetValue(settings, attribute.DefaultValue, null);
                }
            }

            return settings;
        }
示例#6
0
文件: Settings.cs 项目: kcamp/Kekiri
 private Settings(ConfigFileBasedSettings settings)
 {
     _settings = settings;
 }