Example #1
0
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        #region Public Methods

        /// <summary>
        ///     Determines if this list begins with the ContentLocatorParts that
        ///     make up matchList.  All ContentLocatorParts in matchList must
        ///     be present and in the same order in this list for
        ///     true to be returned.
        /// </summary>
        /// <param name="locator">the list to compare with</param>
        /// <returns>
        ///     true if this list begins with the ContentLocatorParts in locator;
        ///     false otherwise.  If locator is longer than this locator, will
        ///     return false as well.
        /// </returns>
        /// <exception cref="ArgumentNullException">locator is null</exception>
        public bool StartsWith(ContentLocator locator)
        {
            if (locator == null)
            {
                throw new ArgumentNullException("locator");
            }

            Invariant.Assert(locator.Parts != null, "Locator has null Parts property.");

            // If this locator is shorter than matchList, then this can't contain matchList.
            #pragma warning suppress 6506 // Invariant.Assert(locator.Parts != null)
            if (this.Parts.Count < locator.Parts.Count)
            {
                return(false);
            }

            for (int locatorPartIndex = 0; locatorPartIndex < locator.Parts.Count; locatorPartIndex++)
            {
                ContentLocatorPart left  = locator.Parts[locatorPartIndex];
                ContentLocatorPart right = this.Parts[locatorPartIndex];

                // ContentLocator parts can be null so check for that case here
                if (left == null && right != null)
                {
                    return(false);
                }

                if (!left.Matches(right))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
 /// <summary>Returns a value that indicates whether the starting sequence of <see cref="T:System.Windows.Annotations.ContentLocatorPart" /> elements in a specified <see cref="T:System.Windows.Annotations.ContentLocator" /> are identical to those in this <see cref="T:System.Windows.Annotations.ContentLocator" />.</summary>
 /// <param name="locator">The <see cref="T:System.Windows.Annotations.ContentLocator" /> with the list of <see cref="T:System.Windows.Annotations.ContentLocatorPart" /> elements to compare with this <see cref="T:System.Windows.Annotations.ContentLocator" />.</param>
 /// <returns>
 ///     <see langword="true" /> if the starting sequence of <see cref="T:System.Windows.Annotations.ContentLocatorPart" /> elements in this <see cref="T:System.Windows.Annotations.ContentLocator" /> matches those in the specified <paramref name="locator" />; otherwise, <see langword="false" />.</returns>
 /// <exception cref="T:System.ArgumentNullException">
 ///         <paramref name="locator" /> is <see langword="null" />.</exception>
 // Token: 0x06006337 RID: 25399 RVA: 0x001BE4EC File Offset: 0x001BC6EC
 public bool StartsWith(ContentLocator locator)
 {
     if (locator == null)
     {
         throw new ArgumentNullException("locator");
     }
     Invariant.Assert(locator.Parts != null, "Locator has null Parts property.");
     if (this.Parts.Count < locator.Parts.Count)
     {
         return(false);
     }
     for (int i = 0; i < locator.Parts.Count; i++)
     {
         ContentLocatorPart contentLocatorPart  = locator.Parts[i];
         ContentLocatorPart contentLocatorPart2 = this.Parts[i];
         if (contentLocatorPart == null && contentLocatorPart2 != null)
         {
             return(false);
         }
         if (!contentLocatorPart.Matches(contentLocatorPart2))
         {
             return(false);
         }
     }
     return(true);
 }