Beispiel #1
0
        private static void UpdateNodeSourceContextWorker(IReadableSelectableTextBuffer textBuffer, DocumentNode node, int startTagLength, int elementLength)
        {
            XmlElementReference elementReference1 = (XmlElementReference)node.SourceContext;
            XmlElementReference elementReference2 = (XmlElementReference)elementReference1.Clone(false);

            if (startTagLength != elementLength)
            {
                elementReference2.StartTagRange = textBuffer.CreateRange(elementReference1.TextRange.Offset, startTagLength);
            }
            elementReference2.SetTextRange(textBuffer, elementReference1.TextRange.Offset, elementLength);
            if (node.DocumentRoot != null)
            {
                node.DocumentRoot.SetSourceContext(node, (INodeSourceContext)elementReference2);
            }
            else
            {
                node.SourceContext = (INodeSourceContext)elementReference2;
            }
        }
        public XmlElementReference BuildXmlElementReference()
        {
            XmlElementReference elementReference1 = this.SourceContext as XmlElementReference;
            DocumentNode        documentNode      = (DocumentNode)this.documentNode.Parent;
            XmlElementReference elementReference2;

            for (elementReference2 = (XmlElementReference)null; documentNode != null && elementReference2 == null; documentNode = (DocumentNode)documentNode.Parent)
            {
                elementReference2 = documentNode.SourceContext as XmlElementReference;
            }
            XmlElementReference elementReference3;

            if (elementReference1 == null)
            {
                if (elementReference2 == null)
                {
                    XmlDocument xmlDocument = new XmlDocument();
                    XmlElement  xmlElement  = new XmlElement(xmlDocument);
                    xmlElement.Parent = (XmlNode)xmlDocument;
                    elementReference3 = new XmlElementReference((XmlContainerReference) new XmlDocumentReference((IReadableSelectableTextBuffer)null, xmlDocument, false), xmlElement, false);
                }
                else
                {
                    elementReference3 = new XmlElementReference((XmlContainerReference)elementReference2, (XmlElement)null, false);
                }
            }
            else
            {
                elementReference3 = (XmlElementReference)elementReference1.Clone(false);
                if (elementReference2 != null)
                {
                    elementReference3.Parent = (XmlContainerReference)elementReference2;
                }
            }
            return(elementReference3);
        }