public XmlElement ToElement(String fieldId) { XmlElement rule = XmlUtils.CreateRootElement("rule"); if (StringUtil.IsEmpty(this.name)) { throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_31001, fieldId); } if (StringUtil.IsEmpty(this.value)) { throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_31002, fieldId); } rule.SetAttribute("name", this.name); rule.SetAttribute("value", this.value); if (!StringUtil.IsEmpty(exProperty)) { rule.SetAttribute("exProperty", this.exProperty); } //for Special if (this.name.Equals(RuleTypeEnumHelper.ToType(RuleTypeEnum.MAX_TARGET_SIZE_RULE))) { MaxTargetSizeRule mtsRule = (MaxTargetSizeRule)this; if (!StringUtil.IsEmpty(mtsRule.Unit)) { rule.SetAttribute("unit", mtsRule.Unit); } } if (this.name.Equals(RuleTypeEnumHelper.ToType(RuleTypeEnum.MIN_TARGET_SIZE_RULE))) { MinTargetSizeRule misRule = (MinTargetSizeRule)this; if (!StringUtil.IsEmpty(misRule.Unit)) { rule.SetAttribute("unit", misRule.Unit); } } if (this.name.Equals(RuleTypeEnumHelper.ToType(RuleTypeEnum.TIP_RULE))) { TipRule tipRule = (TipRule)this; if (!StringUtil.IsEmpty(tipRule.Url)) { rule.SetAttribute("url", tipRule.Url); } } if (this.name.Equals(RuleTypeEnumHelper.ToType(RuleTypeEnum.DEV_TIP_RULE))) { DevTipRule devTipRule = (DevTipRule)this; if (!StringUtil.IsEmpty(devTipRule.Url)) { rule.SetAttribute("url", devTipRule.Url); } } //depend element if (dependGroup != null && !dependGroup.IsEmpty()) { XmlElement depend = dependGroup.ToElement(); XmlUtils.AppendElement(rule, depend); } return(rule); }
public XmlElement ToElement() { XmlElement option = XmlUtils.CreateRootElement("option"); if (StringUtil.IsEmpty(this.displayName)) { throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_33001, null); } if (StringUtil.IsEmpty(this.value)) { throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_33002, null); } option.SetAttribute("displayName", this.displayName); option.SetAttribute("value", this.value); //depend element if (dependGroup != null && !dependGroup.IsEmpty()) { XmlElement depend = dependGroup.ToElement(); XmlUtils.AppendElement(option, depend); } return(option); }