Added check so Util.ReadSettingsFromIniFile doesn't try to set static fields.

GenericGridServerConcept
MW 2009-02-28 16:41:26 +00:00
parent aa5b4b6437
commit da2cbb75b6
1 changed files with 21 additions and 18 deletions

View File

@ -940,25 +940,28 @@ namespace OpenSim.Framework
FieldInfo[] fieldInfos = settingsType.GetFields(); FieldInfo[] fieldInfos = settingsType.GetFields();
foreach (FieldInfo fieldInfo in fieldInfos) foreach (FieldInfo fieldInfo in fieldInfos)
{ {
if (fieldInfo.FieldType == typeof(System.String)) if (!fieldInfo.IsStatic)
{ {
fieldInfo.SetValue(settingsClass, config.Get(fieldInfo.Name, (string)fieldInfo.GetValue(settingsClass))); if (fieldInfo.FieldType == typeof(System.String))
} {
else if (fieldInfo.FieldType == typeof(System.Boolean)) fieldInfo.SetValue(settingsClass, config.Get(fieldInfo.Name, (string)fieldInfo.GetValue(settingsClass)));
{ }
fieldInfo.SetValue(settingsClass, config.GetBoolean(fieldInfo.Name, (bool)fieldInfo.GetValue(settingsClass))); else if (fieldInfo.FieldType == typeof(System.Boolean))
} {
else if (fieldInfo.FieldType == typeof(System.Int32)) fieldInfo.SetValue(settingsClass, config.GetBoolean(fieldInfo.Name, (bool)fieldInfo.GetValue(settingsClass)));
{ }
fieldInfo.SetValue(settingsClass, config.GetInt(fieldInfo.Name, (int)fieldInfo.GetValue(settingsClass))); else if (fieldInfo.FieldType == typeof(System.Int32))
} {
else if (fieldInfo.FieldType == typeof(System.Single)) fieldInfo.SetValue(settingsClass, config.GetInt(fieldInfo.Name, (int)fieldInfo.GetValue(settingsClass)));
{ }
fieldInfo.SetValue(settingsClass, config.GetFloat(fieldInfo.Name, (float)fieldInfo.GetValue(settingsClass))); else if (fieldInfo.FieldType == typeof(System.Single))
} {
else if (fieldInfo.FieldType == typeof(System.UInt32)) fieldInfo.SetValue(settingsClass, config.GetFloat(fieldInfo.Name, (float)fieldInfo.GetValue(settingsClass)));
{ }
fieldInfo.SetValue(settingsClass, System.Convert.ToUInt32(config.Get(fieldInfo.Name, ((uint)fieldInfo.GetValue(settingsClass)).ToString()))); else if (fieldInfo.FieldType == typeof(System.UInt32))
{
fieldInfo.SetValue(settingsClass, System.Convert.ToUInt32(config.Get(fieldInfo.Name, ((uint)fieldInfo.GetValue(settingsClass)).ToString())));
}
} }
} }