Changeset 15 for Common/Registry.cs
- Timestamp:
- Jun 18, 2024, 12:15:33 PM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/Registry.cs
r14 r15 67 67 } 68 68 69 public static double GetValueDouble(this RegistryKey regKey, string name, double defaultValue) 70 { 71 object value = regKey.GetValue(name, defaultValue.ToString()); 72 if (double.TryParse((string)value, out double num)) 73 { 74 return num; 75 } 76 else return defaultValue; 77 } 78 79 public static double? GetValueDoubleNullable(this RegistryKey regKey, string name, double? defaultValue) 80 { 81 object value = regKey.GetValue(name, defaultValue.ToString()); 82 if (double.TryParse((string)value, out double num)) 83 { 84 return num; 85 } 86 else if (value is string && (string)value == "") return null; 87 else return defaultValue; 88 } 89 69 90 public static void SetValueBool(this RegistryKey regKey, string name, bool value) 70 91 { … … 110 131 regKey.SetValue(name, value); 111 132 } 133 134 public static void SetValueDouble(this RegistryKey regKey, string name, double value) 135 { 136 regKey.SetValue(name, value); 137 } 138 139 public static void SetValueDoubleNullable(this RegistryKey regKey, string name, double? value) 140 { 141 if (value != null) 142 { 143 regKey.SetValue(name, value); 144 } 145 else regKey.SetValue(name, ""); 146 } 112 147 } 113 148 }
Note:
See TracChangeset
for help on using the changeset viewer.