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); } } } }
public void ForceLoad() { foreach (PropertyInfo item in config.GetType().GetProperties()) { if (item.PropertyType == typeof(ConfigurationElement)) { ConfigurationElement element = ConfigurationIO.Read(item.Name, instance.Name + "." + config.GetType().Name /*,item.GetValue(config).ToString()*/); if (!string.IsNullOrWhiteSpace(element)) { item.SetValue(config, element); } } } config.onConfigurationLoad(); }