public static void Read(object settings, string key) { RegistryKey subKey = Registry.CurrentUser.CreateSubKey(key); Savior.Read(settings, subKey); }
public static void Read(object settings) { RegistryKey userAppDataRegistry = Application.UserAppDataRegistry; Savior.Read(settings, userAppDataRegistry); }
public static void Read(object settings, RegistryKey Key) { int index; foreach (FieldInfo field in settings.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { if (field.FieldType.IsEnum) { object obj; if ((obj = Key.GetValue(field.Name)) != null) { field.SetValue(settings, Enum.Parse(field.FieldType, (string)obj)); } } else { switch (field.FieldType.Name.ToLower()) { case "string": object obj1; if ((obj1 = Key.GetValue(field.Name)) != null) { field.SetValue(settings, (object)(string)obj1); break; } break; case "boolean": object obj2; if ((obj2 = Key.GetValue(field.Name)) != null) { field.SetValue(settings, (object)bool.Parse((string)obj2)); break; } break; case "int32": object obj3; if ((obj3 = Key.GetValue(field.Name)) != null) { field.SetValue(settings, (object)(int)obj3); break; } break; case "decimal": object obj4; if ((obj4 = Key.GetValue(field.Name)) != null) { int num = (int)obj4; field.SetValue(settings, (object)(Decimal)num); break; } break; case "single": object obj5; if ((obj5 = Key.GetValue(field.Name)) != null) { field.SetValue(settings, (object)float.Parse((string)obj5)); break; } break; case "double": object obj6; if ((obj6 = Key.GetValue(field.Name)) != null) { field.SetValue(settings, (object)double.Parse((string)obj6)); break; } break; case "point": object obj7; if ((obj7 = Key.GetValue(field.Name + ".X")) != null) { int x = (int)obj7; object obj8; if ((obj8 = Key.GetValue(field.Name + ".Y")) != null) { int y = (int)obj8; field.SetValue(settings, (object)new Point(x, y)); } break; } break; case "size": object obj9; if ((obj9 = Key.GetValue(field.Name + ".Height")) != null) { int height = (int)obj9; object obj8; if ((obj8 = Key.GetValue(field.Name + ".Width")) != null) { int width = (int)obj8; field.SetValue(settings, (object)new Size(width, height)); } break; } break; case "string[]": object obj10; if ((obj10 = Key.GetValue(field.Name)) != null) { field.SetValue(settings, (object)(string[])obj10); break; } break; case "byte[]": object obj11; if ((obj11 = Key.GetValue(field.Name)) != null) { field.SetValue(settings, (object)(byte[])obj11); break; } break; case "int32[]": RegistryKey registryKey1; if ((registryKey1 = Key.OpenSubKey(field.Name)) != null) { index = 0; int[] numArray = new int[registryKey1.ValueCount]; object obj8; while ((obj8 = registryKey1.GetValue(index.ToString())) != null) { numArray[index++] = (int)obj8; } field.SetValue(settings, (object)numArray); break; } break; case "single[]": RegistryKey registryKey2; if ((registryKey2 = Key.OpenSubKey(field.Name)) != null) { index = 0; float[] numArray = new float[registryKey2.ValueCount]; object obj8; while ((obj8 = registryKey2.GetValue(index.ToString())) != null) { numArray[index++] = float.Parse((string)obj8); } field.SetValue(settings, (object)numArray); break; } break; case "double[]": RegistryKey registryKey3; if ((registryKey3 = Key.OpenSubKey(field.Name)) != null) { index = 0; double[] numArray = new double[registryKey3.ValueCount]; object obj8; while ((obj8 = registryKey3.GetValue(index.ToString())) != null) { numArray[index++] = double.Parse((string)obj8); } field.SetValue(settings, (object)numArray); break; } break; case "boolean[]": RegistryKey registryKey4; if ((registryKey4 = Key.OpenSubKey(field.Name)) != null) { index = 0; bool[] flagArray = new bool[registryKey4.ValueCount]; object obj8; for (; (obj8 = registryKey4.GetValue(index.ToString())) != null; ++index) { flagArray[index] = bool.Parse((string)obj8); } field.SetValue(settings, (object)flagArray); break; } break; case "color": object obj12; if ((obj12 = Key.GetValue(field.Name)) != null) { string str = (string)obj12; System.Drawing.Color color = !Savior.IsHexadecimal(str) ? System.Drawing.Color.FromName(str) : System.Drawing.Color.FromArgb(int.Parse(str, NumberStyles.HexNumber)); field.SetValue(settings, (object)color); break; } break; case "timespan": object obj13; if ((obj13 = Key.GetValue(field.Name)) != null) { field.SetValue(settings, (object)TimeSpan.Parse((string)obj13)); break; } break; case "datetime": object obj14; if ((obj14 = Key.GetValue(field.Name)) != null) { field.SetValue(settings, (object)DateTime.Parse((string)obj14)); break; } break; case "font": object obj15; if ((obj15 = Key.GetValue(field.Name + ".Name")) != null) { string familyName = (string)obj15; object obj8; if ((obj8 = Key.GetValue(field.Name + ".Size")) != null) { float emSize = float.Parse((string)obj8); object obj16; if ((obj16 = Key.GetValue(field.Name + ".Style")) != null) { FontStyle style = (FontStyle)Enum.Parse(typeof(FontStyle), (string)obj16); field.SetValue(settings, (object)new Font(familyName, emSize, style)); } } break; } break; default: int num1 = (int)MessageBox.Show("This type has not been implemented: " + (object)field.FieldType); break; } } } }