Example #1
0
        public override XmlElement ToParamElement()
        {
            XmlElement fieldNode = XmlUtils.CreateRootElement("field");

            if (StringUtil.IsEmpty(this.id))
            {
                throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_30001, null);
            }
            if (StringUtil.IsEmpty(FieldTypeEnumHelper.ToType(this.type)))
            {
                throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_30002, this.id);
            }
            fieldNode.SetAttribute("id", this.id);
            fieldNode.SetAttribute("name", this.name);
            fieldNode.SetAttribute("type", FieldTypeEnumHelper.ToType(this.type));
            //sub-value
            XmlElement   complexValuesNode = XmlUtils.AppendElement(fieldNode, "complex-values");
            ComplexValue cValue            = this.complexValue;

            foreach (string keyFieldId in cValue.GetFieldKeySet())
            {
                Field      field     = cValue.GetValueField(keyFieldId);
                XmlElement valueNode = field.ToParamElement();
                XmlUtils.AppendElement(complexValuesNode, valueNode);
            }
            return(fieldNode);
        }
Example #2
0
        public override XmlElement ToElement()
        {
            XmlElement fieldNode = XmlUtils.CreateRootElement("field");

            if (StringUtil.IsEmpty(this.id))
            {
                throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_30001, null);
            }
            if (StringUtil.IsEmpty(FieldTypeEnumHelper.ToType(this.type)))
            {
                throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_30002, this.id);
            }
            fieldNode.SetAttribute("id", this.id);
            fieldNode.SetAttribute("name", this.name);
            fieldNode.SetAttribute("type", FieldTypeEnumHelper.ToType(this.type));
            if (this.rules != null && this.rules.Count > 0)
            {
                XmlElement rulesNode = XmlUtils.AppendElement(fieldNode, "rules");
                foreach (Rule rule in this.rules)
                {
                    XmlElement ruleNode = rule.ToElement(this.id);
                    XmlUtils.AppendElement(rulesNode, ruleNode);
                }
            }
            if (this.options != null && this.options.Count > 0)
            {
                XmlElement optionsNode = XmlUtils.AppendElement(fieldNode, "options");
                foreach (Option option in this.options)
                {
                    XmlElement optionNode = option.ToElement();
                    XmlUtils.AppendElement(optionsNode, optionNode);
                }
            }
            if (defaultValueField != null)
            {
                XmlElement defaultValueEle = this.ToDefaultValueElement();
                if (defaultValueEle != null)
                {
                    XmlUtils.AppendElement(fieldNode, defaultValueEle);
                }
            }
            if (this.properties != null && this.properties.Count > 0)
            {
                XmlElement propertiesNode = XmlUtils.AppendElement(fieldNode, "properties");
                foreach (Property.Property propertie in this.properties)
                {
                    XmlElement propertyNode = XmlUtils.AppendElement(propertiesNode, "property");
                    propertyNode.SetAttribute("key", propertie.Key);
                    propertyNode.SetAttribute("value", propertie.Value);
                }
            }
            return(fieldNode);
        }
Example #3
0
        public override XmlElement ToParamElement()
        {
            XmlElement fieldNode = XmlUtils.CreateRootElement("field");

            if (StringUtil.IsEmpty(this.id))
            {
                throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_30001, null);
            }
            if (StringUtil.IsEmpty(FieldTypeEnumHelper.ToType(this.type)))
            {
                throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_30002, this.id);
            }
            fieldNode.SetAttribute("id", this.id);
            fieldNode.SetAttribute("name", this.name);
            fieldNode.SetAttribute("type", FieldTypeEnumHelper.ToType(this.type));
            return(fieldNode);
        }
Example #4
0
        public override XmlElement ToParamElement()
        {
            XmlElement fieldNode = XmlUtils.CreateRootElement("field");

            if (StringUtil.IsEmpty(this.id))
            {
                throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_30001, null);
            }
            if (StringUtil.IsEmpty(FieldTypeEnumHelper.ToType(this.type)))
            {
                throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_30002, this.id);
            }
            fieldNode.SetAttribute("id", this.id);
            fieldNode.SetAttribute("name", this.name);
            fieldNode.SetAttribute("type", FieldTypeEnumHelper.ToType(this.type));
            XmlElement valuesNode = XmlUtils.AppendElement(fieldNode, "values");

            foreach (Value value in values)
            {
                XmlElement valueNode = XmlUtils.AppendElement(valuesNode, "value");
                valueNode.InnerText = value.PropertyValue;
            }
            return(fieldNode);
        }
Example #5
0
 public static Field CreateField(FieldTypeEnum fieldEnum)
 {
     return(FieldTypeEnumHelper.CreateField(fieldEnum));
 }
Example #6
0
        public static Field ElementToField(XmlElement fieldElm)
        {
            if (fieldElm == null)
            {
                return(null);
            }
            String fieldId = XmlUtils.GetAttributeValue(fieldElm, "id");

            if (StringUtil.IsEmpty(fieldId))
            {
                throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_30001, null);
            }
            String fieldType = XmlUtils.GetAttributeValue(fieldElm, "type");

            if (StringUtil.IsEmpty(fieldType))
            {
                throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_30002, fieldId);
            }
            String fieldName = XmlUtils.GetAttributeValue(fieldElm, "name");

            FieldTypeEnum fieldEnum = FieldTypeEnumHelper.GetEnum(fieldType);

            if (fieldEnum == FieldTypeEnum.UNKNOWN)
            {
                throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_30003, fieldId);
            }

            Field field_result = null;

            switch (fieldEnum)
            {
            case FieldTypeEnum.INPUT:
                field_result = ElementToInputField(fieldElm, fieldId, fieldName);
                break;

            case FieldTypeEnum.SINGLECHECK:
                field_result = ElementToSingleCheckField(fieldElm, fieldId, fieldName);
                break;

            case FieldTypeEnum.COMPLEX:
                field_result = ElementToComplexField(fieldElm, fieldId, fieldName);
                break;

            case FieldTypeEnum.MULTICHECK:
                field_result = ElementToMultiCheckField(fieldElm, fieldId, fieldName);
                break;

            case FieldTypeEnum.MULTICOMPLEX:
                field_result = ElementToMultiComplexField(fieldElm, fieldId, fieldName);
                break;

            case FieldTypeEnum.MULTIINPUT:
                field_result = ElementToMultiInputField(fieldElm, fieldId, fieldName);
                break;

            case FieldTypeEnum.LABEL:
                field_result = ElementToLabelField(fieldElm, fieldId, fieldName);
                break;
            }
            return(field_result);
        }