public void TestGenericTypes(BasicMimeType inMimeType, string inMimeTypeStr)
        {
            True(inMimeType != BasicMimeType.none);
            True(inMimeType.IsGenericType());
            True(inMimeTypeStr.NotNulle());
            True(inMimeTypeStr.EndsWith("/none"));

            BasicMimeType mtypeFromStr = BasicMimeTypesX.ParseMimeType(inMimeTypeStr);

            // none; see next line. Tests that MUST have `allowGenericMatchOnNotFound: true`,
            // and that default is the reverse
            True(mtypeFromStr == BasicMimeType.none);

            mtypeFromStr = BasicMimeTypesX.ParseMimeType(inMimeTypeStr, allowGenericMatchOnNotFound: true);
            True(inMimeType == mtypeFromStr);
        }
Exemple #2
0
        /// <summary>
        /// Gets the most qualified mime type, with the first input (<paramref name="primary"/>) overriding the
        /// secondary input.
        /// </summary>
        /// <param name="primary">The primary value.</param>
        /// <param name="secondary">A secondary mime type, which will only override the primary if it is more qualified.</param>
        public static BasicMimeType GetMostQualifiedMimeType(this BasicMimeType primary, BasicMimeType secondary)
        {
            if (primary == BasicMimeType.none)
            {
                return(secondary);
            }

            if (secondary == BasicMimeType.none)
            {
                return(primary);
            }

            if (primary.IsGenericType())
            {
                return(secondary.IsGenericType() ? primary : secondary);
            }

            return(primary);            // primary at this point HAS a subtype, so no matter if secondary is fully set, primary wins at this point
        }
Exemple #3
0
 public static bool IsGenericTypeOrNone(this BasicMimeType mimeType)
 => mimeType == BasicMimeType.none || mimeType.IsGenericType();