Пример #1
0
 public static T ReadRegistryValue <T>(RegistryKey key, string name, T defaultValue)
 {
     try
     {
         string strValue = (string)key.GetValue(name, InvariantConverter.ToString(defaultValue));
         return(InvariantConverter.FromString <T>(strValue));
     }
     catch
     {
         return(defaultValue);
     }
 }
Пример #2
0
 public static IEnumerable <T> ReadRegistryList <T>(RegistryKey key, string baseName)
 {
     for (int index = 1; ; ++index)
     {
         object value = key.GetValue(baseName + index.ToString());
         if (value != null)
         {
             yield return(InvariantConverter.FromString <T>(value.ToString()));
         }
         else
         {
             break;
         }
     }
 }