public static Control CreateFromXml(XmlElement element) { string xmltype = element.Attributes["type"].InnerText; Control control = null; ControlType type = (ControlType)Enum.Parse(typeof(ControlType), xmltype); switch (type) { case ControlType.label: control = new ControlLabel(); break; case ControlType.checkbox: control = new ControlCheckBox(); break; case ControlType.edit: control = new ControlEdit(); break; case ControlType.browse: control = new ControlBrowse(); break; case ControlType.license: control = new ControlLicense(); break; case ControlType.hyperlink: control = new ControlHyperlink(); break; case ControlType.image: control = new ControlImage(); break; default: throw new Exception(string.Format("Invalid type: {0}", xmltype)); } control.FromXml(element); return(control); }
public static Control CreateFromXml(XmlElement element) { string xmltype = element.Attributes["type"].InnerText; Control control = null; ControlType type = (ControlType)Enum.Parse(typeof(ControlType), xmltype); switch (type) { case ControlType.label: control = new ControlLabel(); break; case ControlType.checkbox: control = new ControlCheckBox(); break; case ControlType.edit: control = new ControlEdit(); break; case ControlType.browse: control = new ControlBrowse(); break; case ControlType.license: control = new ControlLicense(); break; case ControlType.hyperlink: control = new ControlHyperlink(); break; case ControlType.image: control = new ControlImage(); break; default: throw new Exception(string.Format("Invalid type: {0}", xmltype)); } control.FromXml(element); return control; }