Exemplo n.º 1
0
 private void LoadTextNode(XmlDiffNode parent, XmlReader reader, PositionInfo pInfo, XmlDiffNodeType nt)
 {
     LoadTextNode(parent, reader.Value, pInfo, nt);
 }
Exemplo n.º 2
0
 private void SetElementEndPosition(XmlDiffElement elem, PositionInfo pInfo)
 {
     Debug.Assert(elem != null);
     elem.EndLineNumber   = pInfo.LineNumber;
     elem.EndLinePosition = pInfo.LinePosition;
 }
Exemplo n.º 3
0
        internal void ReadChildNodes(XmlDiffNode parent, XmlReader reader, PositionInfo pInfo)
        {
            bool lookAhead = false;

            do
            {
                lookAhead = false;
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    LoadElement(parent, reader, pInfo);
                    break;

                case XmlNodeType.Comment:
                    if (!IgnoreComments)
                    {
                        LoadTextNode(parent, reader, pInfo, XmlDiffNodeType.Comment);
                    }
                    break;

                case XmlNodeType.ProcessingInstruction:
                    LoadPI(parent, reader, pInfo);
                    break;

                case XmlNodeType.SignificantWhitespace:
                case XmlNodeType.Whitespace:
                    if (!IgnoreWhitespace)
                    {
                        if (this.WhitespaceAsText)
                        {
                            LoadTextNode(parent, reader, pInfo, XmlDiffNodeType.Text);
                        }
                        else
                        {
                            LoadTextNode(parent, reader, pInfo, XmlDiffNodeType.WS);
                        }
                    }
                    break;

                case XmlNodeType.CDATA:
                    if (!CDataAsText)
                    {
                        LoadTextNode(parent, reader, pInfo, XmlDiffNodeType.CData);
                    }
                    else     //merge with adjacent text/CDATA nodes
                    {
                        StringBuilder text = new StringBuilder();
                        text.Append(reader.Value);
                        while ((lookAhead = reader.Read()) && (reader.NodeType == XmlNodeType.Text || reader.NodeType == XmlNodeType.CDATA))
                        {
                            text.Append(reader.Value);
                        }
                        LoadTextNode(parent, text.ToString(), pInfo, XmlDiffNodeType.Text);
                    }
                    break;

                case XmlNodeType.Text:
                    if (!CDataAsText)
                    {
                        LoadTextNode(parent, reader, pInfo, TextNodeIsWhitespace(reader.Value) ? XmlDiffNodeType.WS : XmlDiffNodeType.Text);
                    }
                    else     //merge with adjacent text/CDATA nodes
                    {
                        StringBuilder text = new StringBuilder();
                        text.Append(reader.Value);
                        while ((lookAhead = reader.Read()) && (reader.NodeType == XmlNodeType.Text || reader.NodeType == XmlNodeType.CDATA))
                        {
                            text.Append(reader.Value);
                        }
                        string txt = text.ToString();
                        LoadTextNode(parent, txt, pInfo, TextNodeIsWhitespace(txt) ? XmlDiffNodeType.WS : XmlDiffNodeType.Text);
                    }
                    break;

                case XmlNodeType.EntityReference:
                    LoadEntityReference(parent, reader, pInfo);
                    break;

                case XmlNodeType.EndElement:
                    SetElementEndPosition(parent as XmlDiffElement, pInfo);
                    return;

                case XmlNodeType.Attribute:     //attribute at top level
                    string attrVal = reader.Name + "=\"" + reader.Value + "\"";
                    LoadTopLevelAttribute(parent, attrVal, pInfo, XmlDiffNodeType.Text);
                    break;

                default:
                    break;
                }
            }while (lookAhead || reader.Read());
        }