Ejemplo n.º 1
0
 public static void WriteRegistryValue <T>(RegistryKey key, string name, T value)
 {
     if (value != null)
     {
         key.SetValue(name, InvariantConverter.ToString(value));
     }
     else
     {
         key.SetValue(name, "");
     }
 }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
0
 public static void WriteRegistryList <T>(RegistryKey key, string baseName, IEnumerable <T> list)
 {
     if (list != null)
     {
         int index = 1;
         foreach (T item in list)
         {
             Utils.WriteRegistryValue(key, baseName + index.ToString(), InvariantConverter.ToString(item));
             ++index;
         }
     }
 }
Ejemplo n.º 4
0
 public static T DeserializeValueFromRegistry <T>(RegistryKey key, string name, T defaultValue)
 {
     try
     {
         string strValue = (string)key.GetValue(name, InvariantConverter.ToString(defaultValue));
         return(DeserializeValue <T>(strValue));
     }
     catch
     {
         return(defaultValue);
     }
 }
 /// <summary>
 /// Converts a value to string using <ref>InvariantConverter</ref>
 /// </summary>
 /// <param name="value">The value to convert.</param>
 /// <returns>The invariant string representation of the value.</returns>
 public static string ToInvString <T>(this T value)
 {
     return(InvariantConverter.ToString(value));
 }