/// <summary>
        /// Gets one or more browser templates in the collection that match the <paramref name="mimeType" />. If no item is found, then
        /// the MIME type that matches the major portion is returned. For example, if the collection does not contain a specific item
        /// for "image/jpeg", then the MIME type for "image/*" is returned. This method returns multiple items when more than one
        /// template has been specified for browsers. That is, all returned items will have the same value for
        /// <see cref="IBrowserTemplate.MimeType" /> but the <see cref="IBrowserTemplate.BrowserId" /> property will vary. At least one
        /// item in the collection will have the <see cref="IBrowserTemplate.BrowserId" /> property set to "default". Guaranteed to not
        /// return null. If no items are found (which shouldn't happen), an empty collection is returned.
        /// </summary>
        /// <param name="mimeType">The MIME type for which to retrieve matching browser templates.</param>
        /// <returns>Returns a <see cref="IBrowserTemplateCollection" /> containing browser templates that match the
        /// <paramref name="mimeType" />. </returns>
        public IBrowserTemplateCollection Get(IMimeType mimeType)
        {
            IBrowserTemplateCollection copy = new BrowserTemplateCollection();

            string fullType = mimeType.FullType;

            foreach (IBrowserTemplate browserTemplate in (List <IBrowserTemplate>)Items)
            {
                if (browserTemplate.MimeType.Equals(fullType, StringComparison.OrdinalIgnoreCase))
                {
                    copy.Add(browserTemplate);
                }
            }

            if (copy.Count == 0)
            {
                // No specific MIME type was found (such as "video/mp4"). Find the generic ones (such as "video/*").
                string genericMimeType = String.Concat(mimeType.MajorType, "/*");
                foreach (IBrowserTemplate browserTemplate in (List <IBrowserTemplate>)Items)
                {
                    if (browserTemplate.MimeType.Equals(genericMimeType, StringComparison.OrdinalIgnoreCase))
                    {
                        copy.Add(browserTemplate);
                    }
                }
            }

            return(copy);
        }
        /// <summary>
        /// Gets one or more browser templates in the collection that match the <paramref name="mimeType" />. If no item is found, then
        /// the MIME type that matches the major portion is returned. For example, if the collection does not contain a specific item
        /// for "image/jpeg", then the MIME type for "image/*" is returned. This method returns multiple items when more than one
        /// template has been specified for browsers. That is, all returned items will have the same value for
        /// <see cref="IBrowserTemplate.MimeType" /> but the <see cref="IBrowserTemplate.BrowserId" /> property will vary. At least one
        /// item in the collection will have the <see cref="IBrowserTemplate.BrowserId" /> property set to "default". Guaranteed to not
        /// return null. If no items are found (which shouldn't happen), an empty collection is returned.
        /// </summary>
        /// <param name="mimeType">The MIME type for which to retrieve matching browser templates.</param>
        /// <returns>Returns a <see cref="IBrowserTemplateCollection" /> containing browser templates that match the
        /// <paramref name="mimeType" />. </returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="mimeType" /> is null.</exception>
        public IBrowserTemplateCollection Find(IMimeType mimeType)
        {
            if (mimeType == null)
            {
                throw new ArgumentNullException("mimeType");
            }

            IBrowserTemplateCollection copy = new BrowserTemplateCollection();

            string fullType = mimeType.FullType;

            foreach (IBrowserTemplate browserTemplate in (List <IBrowserTemplate>)Items)
            {
                if (browserTemplate.MimeType.Equals(fullType, StringComparison.OrdinalIgnoreCase))
                {
                    copy.Add(browserTemplate);
                }
            }

            if (!HasDefaultTemplate(copy))
            {
                // No specific MIME type was found (such as "video/mp4"), or one was found but it
                // didn't have a default variant. Find the generic ones (such as "video/*").
                string genericMimeType = String.Concat(mimeType.MajorType, "/*");
                foreach (IBrowserTemplate browserTemplate in (List <IBrowserTemplate>)Items)
                {
                    if (browserTemplate.MimeType.Equals(genericMimeType, StringComparison.OrdinalIgnoreCase))
                    {
                        copy.Add(browserTemplate);
                    }
                }
            }

            return(copy);
        }
        /// <summary>
        /// Creates a deep copy of this instance.
        /// </summary>
        /// <returns>Returns a deep copy of this instance.</returns>
        public IBrowserTemplateCollection Copy()
        {
            IBrowserTemplateCollection copy = new BrowserTemplateCollection();

            foreach (IBrowserTemplate browserTemplate in (List <IBrowserTemplate>)Items)
            {
                copy.Add(browserTemplate.Copy());
            }

            return(copy);
        }