/// <summary> /// Determine whether an API implementation supports this feature. /// </summary> /// <param name="version"> /// The <see cref="KhronosVersion"/> that specifies the API version. /// </param> /// <param name="extensions"> /// The <see cref="KhronosApi.ExtensionsCollection"/> that specifies the API extensions registry. It can be null. /// </param> /// <returns> /// It returns a <see cref="Boolean"/> that specifies whether this feature is supported by the /// API having the version <paramref name="version"/> and the extensions registry <paramref name="extensions"/>. /// </returns> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="version"/> is null. /// </exception> public bool IsSupported(KhronosVersion version, KhronosApi.ExtensionsCollection extensions) { if (version == null) { throw new ArgumentNullException(nameof(version)); } // Feature is an API version? if (FeatureVersion != null) { // API must match // Note: no need or regex, since Api cannot be a pattern if (version.Api != FeatureVersion.Api) { return(false); } // Profile must match, if defined if (Profile != null && version.Profile != null && Regex.IsMatch(version.Profile, Profile) == false) { return(false); } // API version must be greater than or equal to the required version return(version >= FeatureVersion); } // No API version: indeed it is an API extension if (extensions != null) { // Check compatible API // Note: regex is required since extensions can be implemented by multiple APIs if (Regex.IsMatch(version.Api, Api) == false) { return(false); } // Last chance: extension name return(extensions.HasExtensions(FeatureName)); } else { return(false); } }