Example #1
0
            public int Compare(TypeWithQValue x, TypeWithQValue y)
            {
                if (x == null)
                {
                    throw new ArgumentNullException("x");
                }

                if (y == null)
                {
                    throw new ArgumentNullException("y");
                }

                if (defective)
                {
                    // When browser is defective we have to give precedence Html over XML
                    bool isXHtml = KnownMimeTypes.HtmlTypes().Contains(x.Name, StringComparer.OrdinalIgnoreCase);
                    bool isXXml  = KnownMimeTypes.XmlTypes().Contains(x.Name, StringComparer.OrdinalIgnoreCase);

                    bool isYHtml = KnownMimeTypes.HtmlTypes().Contains(y.Name, StringComparer.OrdinalIgnoreCase);
                    bool isYXml  = KnownMimeTypes.XmlTypes().Contains(y.Name, StringComparer.OrdinalIgnoreCase);

                    if (isXHtml && isYXml)
                    {
                        return(-1);
                    }

                    if (isXXml && isYHtml)
                    {
                        return(1);
                    }
                }

                return(x.Value == y.Value ? x.Ordinal.CompareTo(y.Ordinal) : y.Value.CompareTo(x.Value));
            }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HtmlResponder"/> class.
        /// </summary>
        public HtmlResponder()
        {
            SupportedFormat = "html";

            foreach (string mimeType in KnownMimeTypes.HtmlTypes())
            {
                SupportedMimeTypes.Add(mimeType);
            }
        }