Esempio n. 1
0
        /// <summary>
        ///     Merges this ContentLocator with a ContentLocatorBase.  If other is a
        ///     ContentLocatorGroup, each of its Locators are added to clones of
        ///     this ContentLocatorBase and are added to a new ContentLocatorGroup which is
        ///     returned.  If other is a ContentLocatorBase, its appended to this
        ///     ContentLocatorBase and this ContentLocatorBase is returned.
        ///     Both operation modify this ContentLocatorBase.
        /// </summary>
        /// <param name="other">the ContentLocatorBase to merge with</param>
        /// <returns>a ContentLocatorBase containing the final merged product</returns>
        internal override ContentLocatorBase Merge(ContentLocatorBase other)
        {
            if (other == null)
            {
                return(this);
            }

            ContentLocatorGroup locatorGroup = other as ContentLocatorGroup;

            if (locatorGroup != null)
            {
                ContentLocatorGroup newGroup = new ContentLocatorGroup();

                ContentLocator temp = null;
                // Create n-1 clones of this LPS and append all but one
                // LPSs in the set to the clones, adding the clones to a
                // new ContentLocatorGroup
                foreach (ContentLocator loc in locatorGroup.Locators)
                {
                    if (temp == null)
                    {
                        temp = loc;
                    }
                    else
                    {
                        ContentLocator clone = (ContentLocator)this.Clone();
                        clone.Append(loc);
                        newGroup.Locators.Add(clone);
                    }
                }

                // Finally, add the remaining LPS in the set to this LPS
                // and add this to the new ContentLocatorGroup
                if (temp != null)
                {
                    this.Append(temp);
                    newGroup.Locators.Add(this);
                }

                if (newGroup.Locators.Count == 0)
                {
                    return(this);
                }
                else
                {
                    return(newGroup);
                }
            }
            else
            {
                // Safe cast - ContentLocator only has two subclasses
                this.Append((ContentLocator)other);
                return(this);
            }
        }
Esempio n. 2
0
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        /// <summary>
        ///     Merges the ContentLocatorGroup with a ContentLocatorBase.  If other is a ContentLocatorBase,
        ///     it is added to the end of every ContentLocatorBase in this ContentLocatorGroup.
        ///     If other is a ContentLocatorGroup, then each ContentLocatorBase in it must be added to
        ///     each ContentLocatorBase (or a clone) in this ContentLocatorGroup.  The result is this
        ///     ContentLocatorGroup will contain n*m ContentLocatorBase.
        ///     In both cases, this ContentLocatorGroup is modified.
        /// </summary>
        /// <param name="other">other ContentLocatorBase to merge with</param>
        /// <returns>this ContentLocatorGroup</returns>
        internal override ContentLocatorBase Merge(ContentLocatorBase other)
        {
            if (other == null)
            {
                return(this);
            }

            ContentLocator      firstRight   = null;
            ContentLocatorGroup locatorGroup = other as ContentLocatorGroup;

            if (locatorGroup != null)
            {
                List <ContentLocatorBase> tempList = new List <ContentLocatorBase>(locatorGroup.Locators.Count * (this.Locators.Count - 1));
                foreach (ContentLocator left in this.Locators)
                {
                    foreach (ContentLocator right in locatorGroup.Locators)
                    {
                        if (firstRight == null)
                        {
                            firstRight = right;
                        }
                        else
                        {
                            ContentLocator clone = (ContentLocator)left.Clone();
                            clone.Append(right);
                            tempList.Add(clone);
                        }
                    }

                    // No need to clone or add here - just use the locator
                    // already in the ContentLocatorGroup
                    left.Append(firstRight);
                    firstRight = null;
                }

                foreach (ContentLocator list in tempList)
                {
                    this.Locators.Add(list);
                }
            }
            else
            {
                ContentLocator otherLoc = other as ContentLocator;
                Invariant.Assert(otherLoc != null, "other should be of type ContentLocator");  // Only other possible type for the ContentLocatorBase

                foreach (ContentLocator loc in this.Locators)
                {
                    loc.Append(otherLoc);
                }
            }
            return(this);
        }
        // Token: 0x06006347 RID: 25415 RVA: 0x001BED58 File Offset: 0x001BCF58
        internal override ContentLocatorBase Merge(ContentLocatorBase other)
        {
            if (other == null)
            {
                return(this);
            }
            ContentLocator      contentLocator      = null;
            ContentLocatorGroup contentLocatorGroup = other as ContentLocatorGroup;

            if (contentLocatorGroup != null)
            {
                List <ContentLocatorBase> list = new List <ContentLocatorBase>(contentLocatorGroup.Locators.Count * (this.Locators.Count - 1));
                foreach (ContentLocator contentLocator2 in this.Locators)
                {
                    foreach (ContentLocator contentLocator3 in contentLocatorGroup.Locators)
                    {
                        if (contentLocator == null)
                        {
                            contentLocator = contentLocator3;
                        }
                        else
                        {
                            ContentLocator contentLocator4 = (ContentLocator)contentLocator2.Clone();
                            contentLocator4.Append(contentLocator3);
                            list.Add(contentLocator4);
                        }
                    }
                    contentLocator2.Append(contentLocator);
                    contentLocator = null;
                }
                using (List <ContentLocatorBase> .Enumerator enumerator3 = list.GetEnumerator())
                {
                    while (enumerator3.MoveNext())
                    {
                        ContentLocatorBase contentLocatorBase = enumerator3.Current;
                        ContentLocator     item = (ContentLocator)contentLocatorBase;
                        this.Locators.Add(item);
                    }
                    return(this);
                }
            }
            ContentLocator contentLocator5 = other as ContentLocator;

            Invariant.Assert(contentLocator5 != null, "other should be of type ContentLocator");
            foreach (ContentLocator contentLocator6 in this.Locators)
            {
                contentLocator6.Append(contentLocator5);
            }
            return(this);
        }
Esempio n. 4
0
        // Token: 0x0600633E RID: 25406 RVA: 0x001BEA54 File Offset: 0x001BCC54
        internal override ContentLocatorBase Merge(ContentLocatorBase other)
        {
            if (other == null)
            {
                return(this);
            }
            ContentLocatorGroup contentLocatorGroup = other as ContentLocatorGroup;

            if (contentLocatorGroup == null)
            {
                this.Append((ContentLocator)other);
                return(this);
            }
            ContentLocatorGroup contentLocatorGroup2 = new ContentLocatorGroup();
            ContentLocator      contentLocator       = null;

            foreach (ContentLocator contentLocator2 in contentLocatorGroup.Locators)
            {
                if (contentLocator == null)
                {
                    contentLocator = contentLocator2;
                }
                else
                {
                    ContentLocator contentLocator3 = (ContentLocator)this.Clone();
                    contentLocator3.Append(contentLocator2);
                    contentLocatorGroup2.Locators.Add(contentLocator3);
                }
            }
            if (contentLocator != null)
            {
                this.Append(contentLocator);
                contentLocatorGroup2.Locators.Add(this);
            }
            if (contentLocatorGroup2.Locators.Count == 0)
            {
                return(this);
            }
            return(contentLocatorGroup2);
        }