private void CbOnCheckedChanged(object sender, EventArgs eventArgs) { CheckBox cb = (CheckBox)sender; FieldAndPropertyWrapper arg = (FieldAndPropertyWrapper)cb.Tag; arg.Set(this.ThisAction, cb.Checked); }
/// <summary> /// Populate members from the given Xml Element. /// </summary> /// <remarks> /// Should be implemented if <see cref="Action.AddToXmlElement" /> is /// non-trivially overridden. /// </remarks> /// <param name="element">The XmlElement describing the action</param> protected virtual void PopulateMembersFromXml(XPathNavigator element) { Type actionType = GetType(); //element.Attributes.RemoveNamedItem(@"Assembly"); foreach (XPathNavigator attribute in element.Select(@"./@*")) { if (attribute.Name == @"Assembly") { continue; } FieldAndPropertyWrapper field = (FieldAndPropertyWrapper)actionType.GetMember(attribute.Name).First(); MethodInfo parseMethod = field.MemberType.GetMethod(@"Parse", new[] { typeof(String) }); field.Set(this, parseMethod != null ? parseMethod.Invoke(field, new object[] { attribute.Value }) : attribute.Value); } }
private void attrValue_TextChanged(object sender, EventArgs e) { TextBoxBase attrValue = sender as TextBoxBase; if (attrValue == null) { return; } FieldAndPropertyWrapper f = (FieldAndPropertyWrapper)attrValue.Tag; if (f == null) { return; } ActionArgumentAttribute argInfo = f.GetArgumentAttribute(); object value = f.Get <Object>(ThisAction); MethodInfo parser = f.MemberType.GetMethod(@"Parse", new[] { typeof(String) }); if (parser != null) { try { value = parser.Invoke(f, new object[] { attrValue.Text }); } catch (Exception) { MessageBox.Show(this, String.Format("Invalid Value entered in {0}.{1}: {2}", ThisAction.Name, argInfo.DisplayName, attrValue.Text)); } } else { value = attrValue.Text; } f.Set(ThisAction, value); }