Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        // Token: 0x06007C0B RID: 31755 RVA: 0x0022DF94 File Offset: 0x0022C194
        private int FindMatchingPrefix(ContentLocator[] prefixes, ContentLocatorBase locator, out bool matched)
        {
            matched = true;
            int            result         = 0;
            ContentLocator contentLocator = locator as ContentLocator;

            if (contentLocator != null && prefixes != null && prefixes.Length != 0)
            {
                matched = false;
                foreach (ContentLocator contentLocator2 in prefixes)
                {
                    if (contentLocator.StartsWith(contentLocator2))
                    {
                        result  = contentLocator2.Parts.Count;
                        matched = true;
                        break;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 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);
        }
        /// <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);
        }