static void SetAutoUpdateOption(AutoUpdateOptions options, string name, bool value) { Type myType = options.GetType(); IList <PropertyInfo> myProps = new List <PropertyInfo>(myType.GetProperties()); foreach (PropertyInfo prop in myProps) { foreach (Attribute a in prop.GetCustomAttributes(false)) { IntValueAttribute iva = a as IntValueAttribute; if (iva != null) { if (prop.Name == name) { prop.SetValue(options, value, null); return; } } } } }
private static void GetAddAutoUpdateOptions(ListView listView, AutoUpdateOptions options) { listView.Items.Clear(); Type myType = options.GetType(); IList <PropertyInfo> myProps = new List <PropertyInfo>(myType.GetProperties()); foreach (PropertyInfo prop in myProps) { foreach (Attribute a in prop.GetCustomAttributes(false)) { IntValueAttribute iva = a as IntValueAttribute; if (iva != null) { ListViewItem item = new ListViewItem(prop.Name); bool ret = (bool)prop.GetValue(options, null); item.Checked = ret; listView.Items.Add(item); } } } }
bool ShouldAutoUpdate(int action) { Type myType = Module.Options.AutoUpdateOptions.GetType(); IList <PropertyInfo> myProps = new List <PropertyInfo>(myType.GetProperties()); foreach (PropertyInfo prop in myProps) { foreach (Attribute a in prop.GetCustomAttributes(false)) { IntValueAttribute iva = a as IntValueAttribute; if (iva != null) { if (iva.Value == action) { bool ret = (bool)prop.GetValue(Module.Options.AutoUpdateOptions); return(ret); } } } } return(false); }