/// <summary> /// Writes data to the registery relative to the application base path /// </summary> /// <param name="path">path (relative to the application base path)</param> /// <param name="name">key name</param> /// <param name="value">data to write (may be serilized if not a basic type)</param> public static void storeSetting(string path, string name, object value) { RegistryKey r = ApplicationHelper.appRegistryPath; if (Text.isNotBlank(path)) { r = ApplicationHelper.appRegistryPath.CreateSubKey(path); } //check if in32 compatable if (Querey.search(new Type[] { typeof(sbyte), typeof(byte), typeof(char), typeof(short), typeof(ushort), typeof(int), typeof(uint) }, value.GetType(), new Querey.equalDelegate(typesEqual)) > 0) { //yes int32ish r.SetValue(name, (int)value); } else if (value is string) { r.SetValue(name, value); } else { //attempt to serialise byte[] data = serialise(value); if (data != null) { r.SetValue(name, data); } else { //nothing else has worked to let windows save it as a string r.SetValue(name, value); } } }
/// <summary> /// This function will return def insted of null is the setting is not found /// </summary> /// <param name="path">path (relative to the application base path)</param> /// <param name="name">key name</param> /// <param name="defualt"></param> /// <returns>data at registery (may be deserilized if not a basic type), or def</returns> public static object getSetting(string path, string name, object def) { return(Querey.NVL(getSetting(path, name), def)); }