Beispiel #1
0
        public void ReadFromXml(XmlNode node)
        {
            if (node.Attributes != null)
            {
                _name      = node.Attributes["Name"] == null ? "" : node.Attributes["Name"].Value;
                _aliasName = node.Attributes["AliasName"] == null ? "" : node.Attributes["AliasName"].Value;
                _visible   = node.Attributes["Visible"] == null
                    ? true
                    : (node.Attributes["Visible"].Value.ToUpper().StartsWith("T") ? true : false);
                _dataType = node.Attributes["DataType"] == null
                    ? enumPipelineDataType.Point
                    : EnumHelper.ConvertDataTypeFromString(node.Attributes["DataType"].Value);
                _heightType = node.Attributes["HeightType"] == null
                    ? enumPipelineHeightType.Top
                    : EnumHelper.ConvertHeightTypeFromStr(node.Attributes["HeightType"].Value);

                _depthType = node.Attributes["DepthType"] == null
                   ? enumPipelineDepthType.Relative
                   : EnumHelper.ConvertDepthTypeFromStr(node.Attributes["DepthType"].Value);

                _sectionType = node.Attributes["SectionType"] == null
                   ? enumPipeSectionType.WidthAndHeight
                   : EnumHelper.ConvertSectionTypeFromStr(node.Attributes["SectionType"].Value);

                _validateKeys = node.Attributes["ValidateKeys"] == null ? "" : node.Attributes["ValidateKeys"].Value;
                _templateName = node.Attributes["TemplateName"] == null ? "" : node.Attributes["TemplateName"].Value;
                _autoNames    = node.Attributes["AutoNames"].Value;
            }

            XmlNodeList fieldNodes = node.SelectNodes("Fields/Field");

            foreach (XmlNode fieldNode in fieldNodes)
            {
                IYTField field = new YTField(fieldNode);
                //需要检查已有的字段定义中有没有重名的
                IYTField findField = _fields.FirstOrDefault(c => c.Name == field.Name);
                if (findField != null)
                {
                    _fields.Remove(findField);
                }
                _fields.Add(field);
            }
        }