Esempio n. 1
0
        private static InputField ElementToInputField(XmlElement fieldElm, string fieldId, string fieldName)
        {
            if (fieldElm == null)
            {
                return(null);
            }
            InputField inputField = (InputField)SchemaFactory.CreateField(FieldTypeEnum.INPUT);

            inputField.Id   = fieldId;
            inputField.Name = fieldName;
            //rules
            XmlElement rulesEle = XmlUtils.GetChildElement(fieldElm, "rules");

            if (rulesEle != null)
            {
                List <XmlElement> ruleEleList = XmlUtils.GetChildElements(rulesEle, "rule");
                foreach (XmlElement ruleEle in ruleEleList)
                {
                    Rule rule = ElementToRule(ruleEle, inputField.Id);
                    inputField.Add(rule);
                }
            }
            //property
            XmlElement propertiesEle = XmlUtils.GetChildElement(fieldElm, "properties");

            if (propertiesEle != null)
            {
                List <XmlElement> propertyEleList = XmlUtils.GetChildElements(propertiesEle, "property");
                foreach (XmlElement propertyEle in propertyEleList)
                {
                    Property.Property property = ElementToProperty(propertyEle, inputField.Id);
                    inputField.Add(property);
                }
            }
            //defaultValue
            XmlElement defaultValueEle = XmlUtils.GetChildElement(fieldElm, "default-value");

            if (defaultValueEle != null)
            {
                String dvalue = defaultValueEle.InnerText;
                inputField.SetDefaultValue(dvalue);
            }
            //value
            XmlElement value = XmlUtils.GetChildElement(fieldElm, "value");

            if (value != null)
            {
                inputField.Value = XmlUtils.GetElementValue(value);
            }
            return(inputField);
        }