// Delete all option related entries in registry void ClearRegistry() { foreach (OptionInfo option in Options) { option.Delete(); } _categories.Clear(); Prefs.Delete(allOptionsKey); }
// A function to initializa the OptionSystem Object void Initialize() { Autosave = _autosave; Instance = this; CheckOptionVersion(); // get all classes that have Options attributes var query = from type in Assembly.GetExecutingAssembly().GetTypes() where type.IsClass && type.GetCustomAttributes(typeof(OptionCategoryAttribute), true).Length > 0 select type; var allPropertiesStr = new StringBuilder(); foreach (var type in query) { string categoryClassName = type.FullName; foreach (var property in type.GetProperties()) { allPropertiesStr.Append(categoryClassName) .Append(optionSeperator) .Append(property.Name) .Append(keySeperator); } } // Remove excess characters if (allPropertiesStr.Length > 0) { allPropertiesStr.Remove(allPropertiesStr.Length - 1, 1); } string allProperties = allPropertiesStr.ToString(); IEnumerable <string> currKeys = allProperties.Split(keySeperator); if (Prefs.Exists(allOptionsKey)) { IEnumerable <string> oldKeys = Prefs.GetString(allOptionsKey).Split(keySeperator); var obsoleteKeys = oldKeys.Except(currKeys); foreach (string key in obsoleteKeys) { Prefs.Delete(key); } } Prefs.SetString(allOptionsKey, allProperties); Prefs.Save(); var types = currKeys.Select(k => k.Split(optionSeperator)[0]) .Distinct() .Select(t => Type.GetType(t)) .IgnoreNulls(); foreach (Type type in types) { Get(type); } }
internal void Delete() { Prefs.Delete(Key); }