Пример #1
0
        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);
        }
Пример #2
0
 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;
 }