Example #1
0
        // Token: 0x06007C0D RID: 31757 RVA: 0x0022E17C File Offset: 0x0022C37C
        private ContentLocatorBase GenerateLocatorGroup(PathNode node, object selection)
        {
            SubTreeProcessor    subTreeProcessor    = this.GetSubTreeProcessor(node.Node);
            ContentLocatorGroup contentLocatorGroup = new ContentLocatorGroup();

            foreach (object obj in node.Children)
            {
                PathNode startNode = (PathNode)obj;
                IList <ContentLocatorBase> list = this.GenerateLocators(subTreeProcessor, startNode, selection);
                if (list != null && list.Count > 0 && list[0] != null)
                {
                    ContentLocator contentLocator = list[0] as ContentLocator;
                    if (contentLocator != null && contentLocator.Parts.Count != 0)
                    {
                        contentLocatorGroup.Locators.Add(contentLocator);
                    }
                    else
                    {
                        ContentLocatorGroup contentLocatorGroup2 = list[0] as ContentLocatorGroup;
                    }
                }
            }
            if (contentLocatorGroup.Locators.Count == 0)
            {
                return(null);
            }
            if (contentLocatorGroup.Locators.Count == 1)
            {
                ContentLocator contentLocator2 = contentLocatorGroup.Locators[0];
                contentLocatorGroup.Locators.Remove(contentLocator2);
                return(contentLocator2);
            }
            return(contentLocatorGroup);
        }
Example #2
0
        // Token: 0x06007BBD RID: 31677 RVA: 0x0022C1DC File Offset: 0x0022A3DC
        public Dictionary <Guid, Annotation> FindAnnotations(ContentLocator anchorLocator)
        {
            if (anchorLocator == null)
            {
                throw new ArgumentNullException("locator");
            }
            Dictionary <Guid, Annotation> dictionary = new Dictionary <Guid, Annotation>();

            foreach (StoreAnnotationsMap.CachedAnnotation cachedAnnotation in this._currentAnnotations.Values)
            {
                Annotation annotation = cachedAnnotation.Annotation;
                bool       flag       = false;
                foreach (AnnotationResource annotationResource in annotation.Anchors)
                {
                    foreach (ContentLocatorBase contentLocatorBase in annotationResource.ContentLocators)
                    {
                        ContentLocator contentLocator = contentLocatorBase as ContentLocator;
                        if (contentLocator != null)
                        {
                            if (contentLocator.StartsWith(anchorLocator))
                            {
                                flag = true;
                            }
                        }
                        else
                        {
                            ContentLocatorGroup contentLocatorGroup = contentLocatorBase as ContentLocatorGroup;
                            if (contentLocatorGroup != null)
                            {
                                foreach (ContentLocator contentLocator2 in contentLocatorGroup.Locators)
                                {
                                    if (contentLocator2.StartsWith(anchorLocator))
                                    {
                                        flag = true;
                                        break;
                                    }
                                }
                            }
                        }
                        if (flag)
                        {
                            dictionary.Add(annotation.Id, annotation);
                            break;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
            }
            return(dictionary);
        }
Example #3
0
        /// <summary>
        ///     Queries the store map for annotations that have an anchor
        ///     that contains a locator that begins with the locator parts
        ///     in anchorLocator.
        /// </summary>
        /// <param name="anchorLocator">the locator we are looking for</param>
        /// <returns>
        ///    A list of annotations that have locators in their anchors
        ///    starting with the same locator parts list as of the input locator
        ///    If no such annotations an empty list will be returned. The method
        ///    never returns null.
        /// </returns>
        public Dictionary <Guid, Annotation> FindAnnotations(ContentLocator anchorLocator)
        {
            if (anchorLocator == null)
            {
                throw new ArgumentNullException("locator");
            }

            Dictionary <Guid, Annotation> annotations = new Dictionary <Guid, Annotation>();

            // In the future, this probably has to be done in a way more effecient than linear search
            // the plan of record is to start with this and improve later
            // the map is already solving a perf bottleneck for tablet
            Dictionary <Guid, CachedAnnotation> .ValueCollection.Enumerator annotationsEnumerator = _currentAnnotations.Values.GetEnumerator();

            while (annotationsEnumerator.MoveNext())
            {
                Annotation annotation   = annotationsEnumerator.Current.Annotation;
                bool       matchesQuery = false;

                foreach (AnnotationResource resource in annotation.Anchors)
                {
                    foreach (ContentLocatorBase locator in resource.ContentLocators)
                    {
                        ContentLocator ContentLocator = locator as ContentLocator;
                        if (ContentLocator != null)
                        {
                            if (ContentLocator.StartsWith(anchorLocator))
                            {
                                matchesQuery = true;
                            }
                        }
                        else
                        {
                            ContentLocatorGroup ContentLocatorGroup = locator as ContentLocatorGroup;
                            if (ContentLocatorGroup != null)
                            {
                                foreach (ContentLocator list in ContentLocatorGroup.Locators)
                                {
                                    if (list.StartsWith(anchorLocator))
                                    {
                                        matchesQuery = true;
                                        break;
                                    }
                                }
                            }
                        }

                        if (matchesQuery)
                        {
                            annotations.Add(annotation.Id, annotation);
                            break;
                        }
                    }

                    if (matchesQuery)
                    {
                        break;
                    }
                }
            }

            return(annotations);
        }
Example #4
0
        // Token: 0x06007C10 RID: 31760 RVA: 0x0022E31C File Offset: 0x0022C51C
        private object InternalResolveLocator(ContentLocatorBase locator, int offset, DependencyObject startNode, bool skipStartNode, out AttachmentLevel attachmentLevel)
        {
            attachmentLevel = AttachmentLevel.Full;
            object result = null;
            ContentLocatorGroup contentLocatorGroup = locator as ContentLocatorGroup;
            ContentLocator      contentLocator      = locator as ContentLocator;
            AttachmentLevel     attachmentLevel2    = AttachmentLevel.Unresolved;

            if (contentLocator != null && offset == contentLocator.Parts.Count - 1)
            {
                ContentLocatorPart locatorPart = contentLocator.Parts[offset];
                SelectionProcessor selectionProcessorForLocatorPart = this.GetSelectionProcessorForLocatorPart(locatorPart);
                if (selectionProcessorForLocatorPart != null)
                {
                    result          = selectionProcessorForLocatorPart.ResolveLocatorPart(locatorPart, startNode, out attachmentLevel2);
                    attachmentLevel = attachmentLevel2;
                    return(result);
                }
            }
            IList <ContentLocator> list;

            if (contentLocatorGroup == null)
            {
                list = new List <ContentLocator>(1);
                list.Add(contentLocator);
            }
            else
            {
                AnnotationService service = AnnotationService.GetService(startNode);
                if (service != null)
                {
                    startNode = service.Root;
                }
                list          = contentLocatorGroup.Locators;
                offset        = 0;
                skipStartNode = false;
            }
            bool flag = true;

            if (list.Count > 0)
            {
                LocatorManager.ResolvingLocatorState resolvingLocatorState = this.ResolveSingleLocator(ref result, ref attachmentLevel, AttachmentLevel.StartPortion, list[0], offset, startNode, skipStartNode);
                if (list.Count == 1)
                {
                    result          = resolvingLocatorState.AttachedAnchor;
                    attachmentLevel = resolvingLocatorState.AttachmentLevel;
                }
                else
                {
                    if (list.Count > 2)
                    {
                        AttachmentLevel attachmentLevel3 = AttachmentLevel.Unresolved;
                        AttachmentLevel attachmentLevel4 = attachmentLevel;
                        for (int i = 1; i < list.Count - 1; i++)
                        {
                            resolvingLocatorState = this.ResolveSingleLocator(ref result, ref attachmentLevel, AttachmentLevel.MiddlePortion, list[i], offset, startNode, skipStartNode);
                            if (attachmentLevel3 == AttachmentLevel.Unresolved || (attachmentLevel & AttachmentLevel.MiddlePortion) != AttachmentLevel.Unresolved)
                            {
                                attachmentLevel3 = attachmentLevel;
                            }
                            attachmentLevel = attachmentLevel4;
                        }
                        attachmentLevel = attachmentLevel3;
                    }
                    else
                    {
                        flag = false;
                    }
                    resolvingLocatorState = this.ResolveSingleLocator(ref result, ref attachmentLevel, AttachmentLevel.EndPortion, list[list.Count - 1], offset, startNode, skipStartNode);
                    if (!flag && attachmentLevel == AttachmentLevel.MiddlePortion)
                    {
                        attachmentLevel &= ~AttachmentLevel.MiddlePortion;
                    }
                    if (attachmentLevel == (AttachmentLevel.StartPortion | AttachmentLevel.EndPortion))
                    {
                        attachmentLevel = AttachmentLevel.Full;
                    }
                }
            }
            else
            {
                attachmentLevel = AttachmentLevel.Unresolved;
            }
            return(result);
        }
        /// <summary>
        ///     Queries the store map for annotations that have an anchor
        ///     that contains a locator that begins with the locator parts
        ///     in anchorLocator.
        /// </summary>
        /// <param name="anchorLocator">the locator we are looking for</param>
        /// <returns>
        ///    A list of annotations that have locators in their anchors
        ///    starting with the same locator parts list as of the input locator
        ///    If no such annotations an empty list will be returned. The method
        ///    never returns null.
        /// </returns>
        public Dictionary <Guid, Annotation> FindAnnotations(ContentLocator anchorLocator)
        {
            if (anchorLocator == null)
            {
                throw new ArgumentNullException("locator");
            }

            Dictionary <Guid, Annotation> annotations = new Dictionary <Guid, Annotation>();

            //


            Dictionary <Guid, CachedAnnotation> .ValueCollection.Enumerator annotationsEnumerator = _currentAnnotations.Values.GetEnumerator();

            while (annotationsEnumerator.MoveNext())
            {
                Annotation annotation   = annotationsEnumerator.Current.Annotation;
                bool       matchesQuery = false;

                foreach (AnnotationResource resource in annotation.Anchors)
                {
                    foreach (ContentLocatorBase locator in resource.ContentLocators)
                    {
                        ContentLocator ContentLocator = locator as ContentLocator;
                        if (ContentLocator != null)
                        {
                            if (ContentLocator.StartsWith(anchorLocator))
                            {
                                matchesQuery = true;
                            }
                        }
                        else
                        {
                            ContentLocatorGroup ContentLocatorGroup = locator as ContentLocatorGroup;
                            if (ContentLocatorGroup != null)
                            {
                                foreach (ContentLocator list in ContentLocatorGroup.Locators)
                                {
                                    if (list.StartsWith(anchorLocator))
                                    {
                                        matchesQuery = true;
                                        break;
                                    }
                                }
                            }
                        }

                        if (matchesQuery)
                        {
                            annotations.Add(annotation.Id, annotation);
                            break;
                        }
                    }

                    if (matchesQuery)
                    {
                        break;
                    }
                }
            }

            return(annotations);
        }