示例#1
0
        internal void Load()
        {
            var configType      = config.GetType();
            var holderAttribute = configType.GetCustomAttribute <ConfigurationHolderAttribute>();

            foreach (PropertyInfo item in configType.GetProperties())
            {
                if (item.PropertyType == typeof(ConfigurationElement))
                {
                    ConfigurationElement element = ConfigurationIO.Read(item.Name, name + "." + config.GetType().Name /*,item.GetValue(config).ToString()*/);

                    if (!string.IsNullOrWhiteSpace(element))
                    {
                        if (CheckValueVaild(item, element, holderAttribute))
                        {
                            item.SetValue(config, element);
                        }
                    }
                    else
                    {
                        //if not exist,write to config.ini immediately
                        ConfigurationIO.Write(item.Name, (ConfigurationElement)item.GetValue(config), name + "." + config.GetType().Name);
                    }
                }
            }
        }
示例#2
0
 internal void ForceSave()
 {
     config.onConfigurationSave();
     foreach (PropertyInfo item in config.GetType().GetProperties())
     {
         if (item.PropertyType == typeof(ConfigurationElement))
         {
             ConfigurationIO.Write(item.Name, (ConfigurationElement)item.GetValue(config), name + "." + config.GetType().Name);
         }
     }
 }