Exemple #1
0
        internal static ITextRange GetNodeSpan(ITextBuffer textBuffer, DocumentNode node, bool includeContainer, DocumentNode skipSelf)
        {
            if (textBuffer == null)
            {
                throw new ArgumentNullException("textBuffer");
            }
            ITextRange range = TextRange.Null;

            if (node == skipSelf)
            {
                return(range);
            }
            XamlSourceContext sourceContext1 = node.SourceContext as XamlSourceContext;

            if (sourceContext1 != null && !sourceContext1.IsCloned && sourceContext1.TextRange != null)
            {
                ITextRange other = XamlSerializerUtilities.CaculateTextRange(sourceContext1, textBuffer);
                range = TextRange.Union(range, other);
            }
            XamlSourceContext sourceContext2 = node.ContainerSourceContext as XamlSourceContext;

            if (sourceContext2 != null && !sourceContext2.IsCloned && sourceContext2.TextRange != null && (includeContainer || sourceContext2 is XmlAttributeReference))
            {
                ITextRange other = XamlSerializerUtilities.CaculateTextRange(sourceContext2, textBuffer);
                range = TextRange.Union(range, other);
            }
            if (!TextRange.IsNull(range))
            {
                return(range);
            }
            foreach (DocumentNode node1 in node.ChildNodes)
            {
                range = TextRange.Union(range, XamlSerializerUtilities.GetNodeSpan(textBuffer, node1, true, skipSelf));
            }
            return(range);
        }
Exemple #2
0
 internal static ITextRange GetNodeSpan(ITextBuffer textBuffer, DocumentNode node, bool includeContainer)
 {
     return(XamlSerializerUtilities.GetNodeSpan(textBuffer, node, includeContainer, (DocumentNode)null));
 }