public static void Set(GlobalStringNames name, object value) { if (value == null) { SetString(name, null); } else { var converter = System.ComponentModel.TypeDescriptor.GetConverter(value); var invariantString = converter.ConvertToInvariantString(value); SetString(name, invariantString); } }
public static Nullable <T> Get <T>(GlobalStringNames name) where T : struct { var s = GetString(name.ToString()); if (string.IsNullOrEmpty(s)) { return(null); } else { var converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(T)); Nullable <T> result = null; try { result = (T)converter.ConvertFromInvariantString(s); } catch (Exception) { throw; } return(result); } }
public static void SetString(GlobalStringNames name, string value) { SetString(name.ToString(), value); }
public static string GetString(GlobalStringNames name) { return(GetString(name.ToString())); }