Exemplo n.º 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);
                _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);
            }
        }
Exemplo n.º 2
0
        public void ReadFromXml(XmlNode xml)
        {
            if (xml?.Attributes == null)
            {
                return;
            }
            _name           = xml.Attributes["Name"].Value;
            _aliasName      = xml.Attributes["AliasName"].Value;
            _visible        = Convert.ToBoolean(xml.Attributes["Visible"].Value);
            _heightTypeName = xml.Attributes["HeightType"].Value;
            _heightType     = EnumHelper.ConvertHeightTypeFromStr(_heightTypeName);
            _templateName   = xml.Attributes["Template"].Value;

            XmlNodeList nodeList = xml.SelectNodes("/LineLayer/Fields/Field");

            if (nodeList != null)
            {
                foreach (XmlNode node in nodeList)
                {
                    IYTField field = new YTField(node);
                    _fields.Add(field);
                }
            }
            _noField          = _fields.FirstOrDefault(c => c.TypeName == "NoField");
            _sPointField      = _fields.FirstOrDefault(c => c.TypeName == "SPointField");
            _ePointField      = _fields.FirstOrDefault(c => c.TypeName == "EPointField");
            _sDeepField       = _fields.FirstOrDefault(c => c.TypeName == "SDeepField");
            _eDeepField       = _fields.FirstOrDefault(c => c.TypeName == "EDeepField");
            _shField          = _fields.FirstOrDefault(c => c.TypeName == "SHField");
            _ehField          = _fields.FirstOrDefault(c => c.TypeName == "EHField");
            _codeField        = _fields.FirstOrDefault(c => c.TypeName == "CodeField");
            _materialField    = _fields.FirstOrDefault(c => c.TypeName == "MaterialField");
            _dTypeField       = _fields.FirstOrDefault(c => c.TypeName == "DTypeField");
            _lineStyleField   = _fields.FirstOrDefault(c => c.TypeName == "LineStyleField");
            _dsField          = _fields.FirstOrDefault(c => c.TypeName == "DSField");
            _sectionSizeField = _fields.FirstOrDefault(c => c.TypeName == "SectionSizeField");
            _pdmField         = _fields.FirstOrDefault(c => c.TypeName == "PDMField");
            _pipeNatureField  = _fields.FirstOrDefault(c => c.TypeName == "PipeNatureField");
            _msrqField        = _fields.FirstOrDefault(c => c.TypeName == "MSRQField");
            _mDateField       = _fields.FirstOrDefault(c => c.TypeName == "MDateField");
            _useStatusField   = _fields.FirstOrDefault(c => c.TypeName == "UseStatusField");
            _bCodeField       = _fields.FirstOrDefault(c => c.TypeName == "BCodeField");
            _roadCodeField    = _fields.FirstOrDefault(c => c.TypeName == "RoadCodeField");
            _cabCountField    = _fields.FirstOrDefault(c => c.TypeName == "CabCountField");
            _volPresField     = _fields.FirstOrDefault(c => c.TypeName == "VolPresField");
            _holeCountField   = _fields.FirstOrDefault(c => c.TypeName == "HoleCountField");
            _holeUsedField    = _fields.FirstOrDefault(c => c.TypeName == "HoleUsedField");
            _flowDField       = _fields.FirstOrDefault(c => c.TypeName == "FlowDField");
            _remarkField      = _fields.FirstOrDefault(c => c.TypeName == "RemarkField");
        }