Example #1
0
        // Token: 0x06007C12 RID: 31762 RVA: 0x0022E560 File Offset: 0x0022C760
        private bool ResolveLocatorPart(DependencyObject dependencyObject, LocatorManager.ResolvingLocatorState data, bool visitedViaVisualTree)
        {
            if (data.Finished)
            {
                return(false);
            }
            ContentLocator     contentLocatorBase = data.ContentLocatorBase;
            bool               result             = true;
            ContentLocatorPart contentLocatorPart = contentLocatorBase.Parts[data.LocatorPartIndex];

            if (contentLocatorPart == null)
            {
                result = false;
            }
            SubTreeProcessor subTreeProcessorForLocatorPart = this.GetSubTreeProcessorForLocatorPart(contentLocatorPart);

            if (subTreeProcessorForLocatorPart == null)
            {
                result = false;
            }
            if (contentLocatorPart != null && subTreeProcessorForLocatorPart != null)
            {
                DependencyObject dependencyObject2 = subTreeProcessorForLocatorPart.ResolveLocatorPart(contentLocatorPart, dependencyObject, out result);
                if (dependencyObject2 != null)
                {
                    data.AttachmentLevel = AttachmentLevel.Incomplete;
                    data.AttachedAnchor  = dependencyObject2;
                    result = true;
                    data.LastNodeMatched = dependencyObject2;
                    data.LocatorPartIndex++;
                    if (data.LocatorPartIndex == contentLocatorBase.Parts.Count)
                    {
                        data.AttachmentLevel = AttachmentLevel.Full;
                        data.AttachedAnchor  = dependencyObject2;
                        result = false;
                    }
                    else if (data.LocatorPartIndex == contentLocatorBase.Parts.Count - 1)
                    {
                        contentLocatorPart = contentLocatorBase.Parts[data.LocatorPartIndex];
                        SelectionProcessor selectionProcessorForLocatorPart = this.GetSelectionProcessorForLocatorPart(contentLocatorPart);
                        if (selectionProcessorForLocatorPart != null)
                        {
                            AttachmentLevel attachmentLevel;
                            object          obj = selectionProcessorForLocatorPart.ResolveLocatorPart(contentLocatorPart, dependencyObject2, out attachmentLevel);
                            if (obj != null)
                            {
                                data.AttachmentLevel = attachmentLevel;
                                data.AttachedAnchor  = obj;
                                result = false;
                            }
                            else
                            {
                                result = false;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Example #2
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 #3
0
        // Token: 0x06007C05 RID: 31749 RVA: 0x0022DD80 File Offset: 0x0022BF80
        public IList <ContentLocatorBase> GenerateLocators(object selection)
        {
            base.VerifyAccess();
            if (selection == null)
            {
                throw new ArgumentNullException("selection");
            }
            SelectionProcessor selectionProcessor = this.GetSelectionProcessor(selection.GetType());

            if (selectionProcessor != null)
            {
                ICollection nodes = (ICollection)selectionProcessor.GetSelectedNodes(selection);
                IList <ContentLocatorBase> list = null;
                PathNode pathNode = PathNode.BuildPathForElements(nodes);
                if (pathNode != null)
                {
                    SubTreeProcessor subTreeProcessor = this.GetSubTreeProcessor(pathNode.Node);
                    list = this.GenerateLocators(subTreeProcessor, pathNode, selection);
                }
                if (list == null)
                {
                    list = new List <ContentLocatorBase>(0);
                }
                return(list);
            }
            throw new ArgumentException("Unsupported Selection", "selection");
        }
Example #4
0
        // Token: 0x06007C0F RID: 31759 RVA: 0x0022E2D0 File Offset: 0x0022C4D0
        private bool PostVisit(DependencyObject dependencyObject, LocatorManager.ProcessingTreeState data, bool visitedViaVisualTree)
        {
            bool                        flag             = data.Pop();
            SubTreeProcessor            subTreeProcessor = this.GetSubTreeProcessor(dependencyObject);
            bool                        flag2            = false;
            IList <IAttachedAnnotation> list             = subTreeProcessor.PostProcessNode(dependencyObject, flag, out flag2);

            if (list != null)
            {
                data.AttachedAnnotations.AddRange(list);
            }
            data.CalledProcessAnnotations = (data.CalledProcessAnnotations || flag2 || flag);
            return(true);
        }
Example #5
0
 // Token: 0x06007BFE RID: 31742 RVA: 0x0022D984 File Offset: 0x0022BB84
 public void RegisterSubTreeProcessor(SubTreeProcessor processor, string processorId)
 {
     base.VerifyAccess();
     if (processor == null)
     {
         throw new ArgumentNullException("processor");
     }
     if (processorId == null)
     {
         throw new ArgumentNullException("processorId");
     }
     XmlQualifiedName[] locatorPartTypes = processor.GetLocatorPartTypes();
     this._subtreeProcessors[processorId] = processor;
     if (locatorPartTypes != null)
     {
         foreach (XmlQualifiedName key in locatorPartTypes)
         {
             this._locatorPartHandlers[key] = processor;
         }
     }
 }
Example #6
0
        // Token: 0x06007BFF RID: 31743 RVA: 0x0022D9EC File Offset: 0x0022BBEC
        public SubTreeProcessor GetSubTreeProcessor(DependencyObject node)
        {
            base.VerifyAccess();
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            string text = node.GetValue(LocatorManager.SubTreeProcessorIdProperty) as string;

            if (string.IsNullOrEmpty(text))
            {
                return(this._subtreeProcessors["Id"] as SubTreeProcessor);
            }
            SubTreeProcessor subTreeProcessor = (SubTreeProcessor)this._subtreeProcessors[text];

            if (subTreeProcessor != null)
            {
                return(subTreeProcessor);
            }
            throw new ArgumentException(SR.Get("InvalidSubTreeProcessor", new object[]
            {
                text
            }));
        }
        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------
        
        #region Private Methods

        #region Generating Locators

        /// <summary>
        ///     Walks the path through the element tree specified by 'root' and
        ///     produces a set of locators identifying the path based on
        ///     DependencyProperty settings on the tree.
        /// </summary>
        /// <param name="processor">SubTreeProcessor to use on node</param>
        /// <param name="startNode">the PathNode identifying the root of the subtree to process</param>
        /// <param name="selection">selection for which Locators are being generated</param>
        /// <returns>
        ///     a set of locators identifying the path through the element tree;
        ///     can return null if no locators can be generated for this root
        /// </returns>
        /// <exception cref="ArgumentNullException">root is null</exception>
        /// <exception cref="SystemException">no AnnotationStore is available from
        /// the element tree</exception>
        private IList<ContentLocatorBase> GenerateLocators(SubTreeProcessor processor, PathNode startNode, Object selection)
        {
            Debug.Assert(startNode != null, "startNode can not be null");

            List <ContentLocatorBase> locatorsToReturn = new List<ContentLocatorBase> ();
            bool continueProcessing = true;

            // Process the current PathNode, with the possibilty of doing the whole
            // subtree (in which case continueProcessing comes back false).
            ContentLocator list = processor.GenerateLocator(startNode, out continueProcessing);
            bool processSelection = list != null;
            IList<ContentLocatorBase> newLocators = null;

            // If we should continue processing, we look at the children of the 
            // root.  Depending on the number of children we do  different things.
            if (continueProcessing)
            {
                switch (startNode.Children.Count)
                {
                    case 0 :
                        // No children - we just return what we have so far
                        if (list != null)
                        {
                            locatorsToReturn.Add(list);
                        }

                        break;

                    case 1 :
                        // One child - we ask the root of the subtree for the processor
                        // to use and then ask the processor to handle the subtree.
                        SubTreeProcessor newProcessor = GetSubTreeProcessor(startNode.Node);
                        newLocators = GenerateLocators(newProcessor, (PathNode)startNode.Children[0], selection);

                        if (newLocators != null && newLocators.Count > 0)
                            processSelection = false;

                        if (list != null)
                            locatorsToReturn.AddRange(Merge(list, newLocators));
                        else
                            locatorsToReturn.AddRange(newLocators);

                        break;

                    default :
                        // Multiple children - we must process all the children as a
                        // locator set.  This returns one or more locators that all start
                        // start with a ContentLocatorGroup which can have one locator for each
                        // child.
                        ContentLocatorBase newLocator = GenerateLocatorGroup(startNode, selection);

                        if (newLocator != null)
                            processSelection = false;

                        if (list != null)
                            locatorsToReturn.Add(list.Merge(newLocator));
                        else if (newLocator != null)
                            locatorsToReturn.Add(newLocator);
                        break;
                }
            }
            else
            {
                // If we shouldn't continue processing we package up the
                // locator we got from the first GenerateLocator call
                if (list != null)
                {
                    locatorsToReturn.Add(list);
                }
            }

            // If we produced a locator for root and no one below us did as well,
            // we need to process the selection, if any
            if (processSelection && selection != null)
            {
                SelectionProcessor selProcessor = GetSelectionProcessor(selection.GetType());

                if (selProcessor != null)
                {
                    IList <ContentLocatorPart> locatorParts = selProcessor.GenerateLocatorParts(selection, startNode.Node);
                    // Possible bug - AddLocatorPartsToLocator was only written to handle normal locators, not
                    // locator groups. ToDo
                    if (locatorParts != null && locatorParts.Count > 0)
                    {
                        List<ContentLocatorBase> tempLocators = new List<ContentLocatorBase>(locatorsToReturn.Count * locatorParts.Count);

                        foreach (ContentLocatorBase loc in locatorsToReturn)
                        {
                            tempLocators.AddRange(((ContentLocator)loc).DotProduct(locatorParts));  // 
                        }

                        locatorsToReturn = tempLocators;
                    }
                }
            }

            return locatorsToReturn;
        }
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        #region Public Methods

        #region Processor Caches

        /// <summary>
        ///     Registers a subtree processor.  The processorId is the string to be
        ///     used as the value of the SubTreeProcessorIdProperty for this processor.
        ///     This call overrides any previous registrations for processorId or for
        ///     the locator part types recognized by processor.
        /// </summary>
        /// <param name="processor">instance to be registered</param>
        /// <param name="processorId">string id used to specify this processor as 
        /// the SubTreeProcessorIdProperty value</param>
        /// <exception cref="ArgumentNullException">if the processor or processorId are null</exception>
        public void RegisterSubTreeProcessor(SubTreeProcessor processor, String processorId)
        {
            VerifyAccess();
            if (processor == null)
                throw new ArgumentNullException("processor");

            if (processorId == null)
                throw new ArgumentNullException("processorId");

            XmlQualifiedName[] locatorPartTypes = processor.GetLocatorPartTypes();
            
            _subtreeProcessors[processorId] = processor;

            if (locatorPartTypes != null)
            {
                foreach (XmlQualifiedName typeName in locatorPartTypes)
                {
                    _locatorPartHandlers[typeName] = processor;
                }
            }
        }
Example #9
0
        // Token: 0x06007C0C RID: 31756 RVA: 0x0022DFEC File Offset: 0x0022C1EC
        private IList <ContentLocatorBase> GenerateLocators(SubTreeProcessor processor, PathNode startNode, object selection)
        {
            List <ContentLocatorBase> list = new List <ContentLocatorBase>();
            bool           flag            = true;
            ContentLocator contentLocator  = processor.GenerateLocator(startNode, out flag);
            bool           flag2           = contentLocator != null;

            if (flag)
            {
                int count = startNode.Children.Count;
                if (count != 0)
                {
                    if (count != 1)
                    {
                        ContentLocatorBase contentLocatorBase = this.GenerateLocatorGroup(startNode, selection);
                        if (contentLocatorBase != null)
                        {
                            flag2 = false;
                        }
                        if (contentLocator != null)
                        {
                            list.Add(contentLocator.Merge(contentLocatorBase));
                        }
                        else if (contentLocatorBase != null)
                        {
                            list.Add(contentLocatorBase);
                        }
                    }
                    else
                    {
                        SubTreeProcessor           subTreeProcessor = this.GetSubTreeProcessor(startNode.Node);
                        IList <ContentLocatorBase> list2            = this.GenerateLocators(subTreeProcessor, (PathNode)startNode.Children[0], selection);
                        if (list2 != null && list2.Count > 0)
                        {
                            flag2 = false;
                        }
                        if (contentLocator != null)
                        {
                            list.AddRange(this.Merge(contentLocator, list2));
                        }
                        else
                        {
                            list.AddRange(list2);
                        }
                    }
                }
                else if (contentLocator != null)
                {
                    list.Add(contentLocator);
                }
            }
            else if (contentLocator != null)
            {
                list.Add(contentLocator);
            }
            if (flag2 && selection != null)
            {
                SelectionProcessor selectionProcessor = this.GetSelectionProcessor(selection.GetType());
                if (selectionProcessor != null)
                {
                    IList <ContentLocatorPart> list3 = selectionProcessor.GenerateLocatorParts(selection, startNode.Node);
                    if (list3 != null && list3.Count > 0)
                    {
                        List <ContentLocatorBase> list4 = new List <ContentLocatorBase>(list.Count * list3.Count);
                        foreach (ContentLocatorBase contentLocatorBase2 in list)
                        {
                            list4.AddRange(((ContentLocator)contentLocatorBase2).DotProduct(list3));
                        }
                        list = list4;
                    }
                }
            }
            return(list);
        }