/// <summary>
        /// 从对象的 XML 表示形式生成该对象。
        /// </summary>
        /// <param name="reader">从中对对象进行反序列化的 <see cref="T:System.Xml.XmlReader" /> 流。</param>
        public override void ReadXml(XmlReader reader)
        {
            int entDepth = reader.Depth;

            //处理开始节点
            if (reader.NodeType == XmlNodeType.Element && reader.Name == "when")
            {
                reader.ReadToElement("match");
                if (reader.Name == "match")
                {
                    ConditionalElement myWhen = new ConditionalElement();
                    myWhen.ReadXml(reader);
                    Match = myWhen;

                    if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "match")
                    {
                        reader.ReadEndElement();
                    }
                }

                reader.ReadToElement("invoke");
                if (reader.Name == "invoke")
                {
                    reader.ReadToElement(null);
                    while (reader.NodeType == XmlNodeType.Element)
                    {
                        _innerSteps.ReadXmlEx <ModuleBuildStepElement>(reader);
                    }
                    if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "invoke")
                    {
                        reader.ReadEndElement();
                    }
                }

                if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "when")
                {
                    reader.ReadEndElement();
                }
            }
        }
Example #2
0
        /// <summary>
        /// 从对象的 XML 表示形式生成该对象。
        /// </summary>
        /// <param name="reader">从中对对象进行反序列化的 <see cref="T:System.Xml.XmlReader" /> 流。</param>
        public override void ReadXml(XmlReader reader)
        {
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    if (reader.Name == "moduleId")
                    {
                        ModuleId = reader.Value;
                    }
                    else if (reader.Name == "type")
                    {
                        Type = reader.Value;
                    }
                    else if (reader.Name == "isInstance")
                    {
                        BuildInstance = Convert.ToBoolean(reader.Value);
                    }
                    else if (reader.Name == "target")
                    {
                        Target = (BuildTarget)Enum.Parse(typeof(BuildTarget), reader.Value);
                    }
                    else if (reader.Name == "enumerator")
                    {
                        ScopeIEnumerableInstance = reader.Value;
                    }
                }
            }

            int entDepth = reader.Depth;

            while (reader.Read() && reader.Depth >= entDepth)
            {
                //处理开始节点
                while (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "match")
                    {
                        ConditionalElement myWhen = new ConditionalElement();
                        myWhen.ReadXml(reader);
                        Match = myWhen;
                        if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "match")
                        {
                            reader.ReadEndElement();
                        }
                    }

                    if (reader.Name == "invoke")
                    {
                        reader.Read();
                        while (reader.NodeType == XmlNodeType.Element)
                        {
                            _innerSteps.ReadXmlEx <ModuleBuildStepElement>(reader);
                        }
                        if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "invoke")
                        {
                            reader.ReadEndElement();
                        }
                    }
                }
            }
        }