Пример #1
0
		internal virtual void ReadContent (MSBuildXmlReader reader)
		{
			if (reader.IsEmptyElement) {
				reader.Skip ();
				return;
			}
			var elemName = reader.LocalName;

			reader.Read ();
			bool childFound = false;

			while (reader.NodeType != XmlNodeType.EndElement) {
				if (reader.NodeType == XmlNodeType.Element) {
					if (!childFound) {
						childFound = true;
						StartInnerWhitespace = reader.ConsumeWhitespaceUntilNewLine ();
					}
					ReadChildElement (reader);
				} else if (reader.NodeType == XmlNodeType.Text) {
					if (!SupportsTextContent)
						throw new MSBuildFileFormatException ("Text content is not allowed inside a " + elemName + " element");
					if (!childFound) {
						childFound = true;
						StartInnerWhitespace = reader.ConsumeWhitespaceUntilNewLine ();
					}
					var tn = new MSBuildXmlTextNode ();
					tn.Read (reader);
					ChildNodes = ChildNodes.Add (tn);
				} else if (reader.NodeType == XmlNodeType.CDATA) {
					if (!childFound) {
						childFound = true;
						StartInnerWhitespace = reader.ConsumeWhitespaceUntilNewLine ();
					}
					var tn = new MSBuildXmlCDataNode ();
					tn.Read (reader);
					ChildNodes = ChildNodes.Add (tn);
				} else if (reader.NodeType == XmlNodeType.Comment) {
					if (!childFound) {
						childFound = true;
						StartInnerWhitespace = reader.ConsumeWhitespaceUntilNewLine ();
					}
					var tn = new MSBuildXmlCommentNode ();
					tn.Read (reader);
					ChildNodes = ChildNodes.Add (tn);
				} else if (reader.IsWhitespace) {
					reader.ReadAndStoreWhitespace ();
				} else if (reader.EOF)
					throw new InvalidOperationException ("Invalid XML");
				else
					reader.Read ();
			}
			reader.Read ();

			EndInnerWhitespace = reader.ConsumeWhitespace ();
		}
Пример #2
0
        internal virtual void ReadContent(MSBuildXmlReader reader)
        {
            if (reader.IsEmptyElement)
            {
                reader.Skip();
                return;
            }
            var elemName = reader.LocalName;

            reader.Read();
            bool childFound = false;

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (!childFound)
                    {
                        childFound           = true;
                        StartInnerWhitespace = reader.ConsumeWhitespaceUntilNewLine();
                    }
                    ReadChildElement(reader);
                }
                else if (reader.NodeType == XmlNodeType.Text)
                {
                    if (!SupportsTextContent)
                    {
                        throw new MSBuildFileFormatException("Text content is not allowed inside a " + elemName + " element");
                    }
                    if (!childFound)
                    {
                        childFound           = true;
                        StartInnerWhitespace = reader.ConsumeWhitespaceUntilNewLine();
                    }
                    var tn = new MSBuildXmlTextNode();
                    tn.Read(reader);
                    ChildNodes = ChildNodes.Add(tn);
                }
                else if (reader.NodeType == XmlNodeType.CDATA)
                {
                    if (!childFound)
                    {
                        childFound           = true;
                        StartInnerWhitespace = reader.ConsumeWhitespaceUntilNewLine();
                    }
                    var tn = new MSBuildXmlCDataNode();
                    tn.Read(reader);
                    ChildNodes = ChildNodes.Add(tn);
                }
                else if (reader.NodeType == XmlNodeType.Comment)
                {
                    if (!childFound)
                    {
                        childFound           = true;
                        StartInnerWhitespace = reader.ConsumeWhitespaceUntilNewLine();
                    }
                    var tn = new MSBuildXmlCommentNode();
                    tn.Read(reader);
                    ChildNodes = ChildNodes.Add(tn);
                }
                else if (reader.IsWhitespace)
                {
                    reader.ReadAndStoreWhitespace();
                }
                else if (reader.EOF)
                {
                    throw new InvalidOperationException("Invalid XML");
                }
                else
                {
                    reader.Read();
                }
            }
            reader.Read();

            EndInnerWhitespace = reader.ConsumeWhitespace();
        }