public static Dictionary <int, Tuple <bool, string, string, string> > GetPropertyDictionary(Styx.Helpers.Settings objectType) { var retval = new Dictionary <int, Tuple <bool, string, string, string> >(); var propertyList = objectType.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); if (propertyList != null) { foreach (var propertyInfo in propertyList) { if ( Attribute.IsDefined(propertyInfo, typeof(SettingCategoryNameAttribute)) && Attribute.IsDefined(propertyInfo, typeof(SettingGroupNameAttribute)) && Attribute.IsDefined(propertyInfo, typeof(SettingSpellIDAttribute)) ) { var spellID = GetSpellIDAttributeValue(propertyInfo); var displayName = GetSettingNameAttributeValue(propertyInfo, spellID); var categoryName = GetCategoryNameAttributeValue(propertyInfo); var groupName = GetGroupNameAttributeValue(propertyInfo); var propertyValue = (bool)propertyInfo.GetValue(objectType); retval.Add(spellID, new Tuple <bool, string, string, string>(propertyValue, displayName, categoryName, groupName)); } } } return(retval); }
public static void SetPropertyValue(Styx.Helpers.Settings objectType, bool value, int spellID) { var propertyList = objectType.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); if (propertyList != null) { foreach (var propertyInfo in propertyList) { if (!Attribute.IsDefined(propertyInfo, typeof(SettingSpellIDAttribute))) { continue; } var spell = GetSpellIDAttributeValue(propertyInfo); if (spell == spellID) { propertyInfo.SetValue(objectType, value); return; } } } }