예제 #1
0
 public static void ClearSourceContextInitialRanges(DocumentNode node)
 {
     XamlSerializerUtilities.ClearSourceContextInitialRange(node.SourceContext);
     XamlSerializerUtilities.ClearSourceContextInitialRange(node.ContainerSourceContext);
     foreach (DocumentNode node1 in node.ChildNodes)
     {
         XamlSerializerUtilities.ClearSourceContextInitialRanges(node1);
     }
 }
예제 #2
0
 private static void UpdateSourceContextRangeFromInitialRangeWorker(IReadableSelectableTextBuffer textBuffer, DocumentNode node, int offset)
 {
     node.ClearOldSourceContainerContext();
     XamlSerializerUtilities.UpdateSourceContextRangeFromInitialRange(textBuffer, node.SourceContext, offset);
     XamlSerializerUtilities.UpdateSourceContextRangeFromInitialRange(textBuffer, node.ContainerSourceContext, offset);
     foreach (DocumentNode node1 in node.ChildNodes)
     {
         XamlSerializerUtilities.UpdateSourceContextRangeFromInitialRangeWorker(textBuffer, node1, offset);
     }
 }
예제 #3
0
        public static void UpdateNodeSourceContext(IReadableSelectableTextBuffer textBuffer, DocumentNode node, int startTagLength, int elementLength)
        {
            DocumentNode node1 = (DocumentNode)node.Parent;

            if (node1 != null && typeof(DictionaryEntry).IsAssignableFrom(node1.TargetType) && node1.SourceContext is XmlElementReference)
            {
                XamlSerializerUtilities.UpdateNodeSourceContextWorker(textBuffer, node1, startTagLength, elementLength);
            }
            XamlSerializerUtilities.UpdateNodeSourceContextWorker(textBuffer, node, startTagLength, elementLength);
        }
예제 #4
0
        private static void UpdateSourceContextRangeFromInitialRange(IReadableSelectableTextBuffer textBuffer, INodeSourceContext context, int offset)
        {
            XamlSourceContext xamlSourceContext = context as XamlSourceContext;

            if (xamlSourceContext == null)
            {
                return;
            }
            if (!TextRange.IsNull(xamlSourceContext.InitialTextSpan))
            {
                ITextRange initialTextSpan = xamlSourceContext.InitialTextSpan;
                ITextRange textRange1      = (ITextRange) new TextRange(initialTextSpan.Offset + offset, initialTextSpan.Offset + initialTextSpan.Length + offset);
                xamlSourceContext.InitialTextSpan = textRange1;
                xamlSourceContext.SetTextRange(textBuffer, textRange1.Offset, textRange1.Length);
                XmlElementReference elementReference = xamlSourceContext as XmlElementReference;
                if (elementReference == null)
                {
                    return;
                }
                foreach (XmlElementReference.Attribute attribute in elementReference.AttributesToPreserve)
                {
                    XamlSerializerUtilities.UpdateSourceContextRangeFromInitialRange(textBuffer, (INodeSourceContext)attribute.SourceContext, offset);
                }
                if (TextRange.IsNull(elementReference.InitialStartTagSpan))
                {
                    return;
                }
                ITextRange initialStartTagSpan = elementReference.InitialStartTagSpan;
                ITextRange textRange2          = (ITextRange) new TextRange(initialStartTagSpan.Offset + offset, initialStartTagSpan.Offset + initialStartTagSpan.Length + offset);
                elementReference.InitialStartTagSpan = textRange2;
                elementReference.StartTagRange       = textBuffer.CreateRange(textRange2.Offset, textRange2.Length);
            }
            else
            {
                xamlSourceContext.ClearTextRange();
                XmlElementReference elementReference = xamlSourceContext as XmlElementReference;
                if (elementReference == null)
                {
                    return;
                }
                elementReference.StartTagRange = (ITextRange)null;
            }
        }
예제 #5
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);
        }
예제 #6
0
 internal static ITextRange GetNodeSpan(ITextBuffer textBuffer, DocumentNode node, bool includeContainer)
 {
     return(XamlSerializerUtilities.GetNodeSpan(textBuffer, node, includeContainer, (DocumentNode)null));
 }
예제 #7
0
 public static void UpdateSourceContextRangeFromInitialRange(IReadableSelectableTextBuffer textBuffer, DocumentNode node, int offset)
 {
     XamlSerializerUtilities.UpdateSourceContextRangeFromInitialRangeWorker(textBuffer, node, offset);
     XamlSerializerUtilities.RefreshSiblingOrdering(node);
 }