// Token: 0x06007C49 RID: 31817 RVA: 0x0022F5F8 File Offset: 0x0022D7F8
        internal static void GetMaxMinLocatorPartValues(ContentLocatorPart locatorPart, out int startOffset, out int endOffset)
        {
            if (locatorPart == null)
            {
                throw new ArgumentNullException("locatorPart");
            }
            string text = locatorPart.NameValuePairs["Count"];

            if (text == null)
            {
                throw new ArgumentException(SR.Get("InvalidLocatorPart", new object[]
                {
                    "Count"
                }));
            }
            int num = int.Parse(text, NumberFormatInfo.InvariantInfo);

            startOffset = int.MaxValue;
            endOffset   = 0;
            for (int i = 0; i < num; i++)
            {
                int num2;
                int num3;
                TextSelectionProcessor.GetLocatorPartSegmentValues(locatorPart, i, out num2, out num3);
                if (num2 < startOffset)
                {
                    startOffset = num2;
                }
                if (num3 > endOffset)
                {
                    endOffset = num3;
                }
            }
        }
        // Token: 0x06007C46 RID: 31814 RVA: 0x0022F3A8 File Offset: 0x0022D5A8
        public override object ResolveLocatorPart(ContentLocatorPart locatorPart, DependencyObject startNode, out AttachmentLevel attachmentLevel)
        {
            if (startNode == null)
            {
                throw new ArgumentNullException("startNode");
            }
            if (locatorPart == null)
            {
                throw new ArgumentNullException("locatorPart");
            }
            if (TextSelectionProcessor.CharacterRangeElementName != locatorPart.PartType)
            {
                throw new ArgumentException(SR.Get("IncorrectLocatorPartType", new object[]
                {
                    locatorPart.PartType.Namespace + ":" + locatorPart.PartType.Name
                }), "locatorPart");
            }
            int    num  = 0;
            int    num2 = 0;
            string text = locatorPart.NameValuePairs["Count"];

            if (text == null)
            {
                throw new ArgumentException(SR.Get("InvalidLocatorPart", new object[]
                {
                    "Count"
                }));
            }
            int        num3       = int.Parse(text, NumberFormatInfo.InvariantInfo);
            TextAnchor textAnchor = new TextAnchor();

            attachmentLevel = AttachmentLevel.Unresolved;
            for (int i = 0; i < num3; i++)
            {
                TextSelectionProcessor.GetLocatorPartSegmentValues(locatorPart, i, out num, out num2);
                ITextPointer textPointer;
                ITextPointer textPointer2;
                if (!this.GetNodesStartAndEnd(startNode, out textPointer, out textPointer2))
                {
                    return(null);
                }
                int offsetToPosition = textPointer.GetOffsetToPosition(textPointer2);
                if (num > offsetToPosition)
                {
                    return(null);
                }
                ITextPointer textPointer3 = textPointer.CreatePointer(num);
                ITextPointer textPointer4 = (offsetToPosition <= num2) ? textPointer2.CreatePointer() : textPointer.CreatePointer(num2);
                if (textPointer3.CompareTo(textPointer4) >= 0)
                {
                    return(null);
                }
                textAnchor.AddTextSegment(textPointer3, textPointer4);
            }
            if (textAnchor.IsEmpty)
            {
                throw new ArgumentException(SR.Get("IncorrectAnchorLength"), "locatorPart");
            }
            attachmentLevel = AttachmentLevel.Full;
            if (this._clamping)
            {
                ITextPointer     start = textAnchor.Start;
                ITextPointer     end   = textAnchor.End;
                IServiceProvider serviceProvider;
                if (this._targetPage != null)
                {
                    serviceProvider = this._targetPage;
                }
                else
                {
                    FlowDocument node = start.TextContainer.Parent as FlowDocument;
                    serviceProvider = (PathNode.GetParent(node) as IServiceProvider);
                }
                Invariant.Assert(serviceProvider != null, "No ServiceProvider found to get TextView from.");
                ITextView textView = serviceProvider.GetService(typeof(ITextView)) as ITextView;
                Invariant.Assert(textView != null, "Null TextView provided by ServiceProvider.");
                textAnchor = TextAnchor.TrimToIntersectionWith(textAnchor, textView.TextSegments);
                if (textAnchor == null)
                {
                    attachmentLevel = AttachmentLevel.Unresolved;
                }
                else
                {
                    if (textAnchor.Start.CompareTo(start) != 0)
                    {
                        attachmentLevel &= ~AttachmentLevel.StartPortion;
                    }
                    if (textAnchor.End.CompareTo(end) != 0)
                    {
                        attachmentLevel &= ~AttachmentLevel.EndPortion;
                    }
                }
            }
            return(textAnchor);
        }