private static bool IsCompatible_RequiredAttribute(RegistryAssemblyConfiguration cfg, CustomAttribute customAttrib) { string featureName = customAttrib.ConstructorArguments[0].Value as string; KhronosVersion attribVersion = KhronosVersion.ParseFeature(featureName, false); // Match at least one feature? bool compatible = false; foreach (RegistryAssemblyConfiguration.VersionRange cfgFeature in cfg.Features) { if (cfgFeature.Api != null) { CustomAttributeNamedArgument apiArg = customAttrib.Fields.FirstOrDefault(delegate(CustomAttributeNamedArgument item) { return(item.Name == "Api"); }); string apiRegex = apiArg.Argument.Value != null ? apiArg.Argument.Value as string : "gl"; if (Regex.IsMatch(cfgFeature.Api, "^(" + apiRegex + ")$")) { compatible |= true; } } if (cfgFeature.Profile != null) { CustomAttributeNamedArgument apiArg = customAttrib.Fields.FirstOrDefault(delegate(CustomAttributeNamedArgument item) { return(item.Name == "Profile"); }); string apiRegex = apiArg.Argument.Value != null ? apiArg.Argument.Value as string : null; if (apiRegex != null) { compatible &= Regex.IsMatch(cfgFeature.Profile, "^(" + apiRegex + ")$"); } } if (attribVersion != null) { KhronosVersion minVersion = /*cfgFeature.MinApiVersion != null ? KhronosVersion.Parse(cfgFeature.MinApiVersion) :*/ null; KhronosVersion maxVersion = /*cfgFeature.MaxApiVersion != null ? KhronosVersion.Parse(cfgFeature.MaxApiVersion) :*/ null; // API version if (minVersion != null && attribVersion < minVersion) { return(false); } if (maxVersion != null && attribVersion > maxVersion) { return(false); } } else { // Extension (Api must match) if (compatible) { compatible &= cfg.Extensions.Contains(featureName); } } } return(compatible); }
private static bool IsCompatible_RemovedAttribute(RegistryAssemblyConfiguration cfg, CustomAttribute customAttrib) { string featureName = customAttrib.ConstructorArguments[0].Value as string; KhronosVersion attribVersion = KhronosVersion.ParseFeature(featureName, false); if (attribVersion == null) { return(true); } return(cfg.Features.All(cfgFeature => cfgFeature.Api == null || cfgFeature.Api != attribVersion.Api)); }
public void KhronosVersion_ParseFeature() { Assert.Throws <ArgumentNullException>(() => KhronosVersion.ParseFeature(null)); Assert.AreEqual(new KhronosVersion(1, 0, KhronosVersion.ApiGl), KhronosVersion.ParseFeature("GL_VERSION_1_0")); Assert.AreEqual(new KhronosVersion(2, 1, KhronosVersion.ApiGl), KhronosVersion.ParseFeature("GL_VERSION_2_1")); Assert.AreEqual(new KhronosVersion(1, 4, KhronosVersion.ApiEgl), KhronosVersion.ParseFeature("EGL_VERSION_1_4")); Assert.AreEqual(new KhronosVersion(1, 4, KhronosVersion.ApiGlx), KhronosVersion.ParseFeature("GLX_VERSION_1_4")); Assert.AreEqual(new KhronosVersion(1, 0, KhronosVersion.ApiWgl), KhronosVersion.ParseFeature("WGL_VERSION_1_0")); Assert.AreEqual(new KhronosVersion(1, 0, KhronosVersion.ApiGles1), KhronosVersion.ParseFeature("GL_VERSION_ES_CM_1_0")); Assert.AreEqual(new KhronosVersion(3, 2, KhronosVersion.ApiGles2), KhronosVersion.ParseFeature("GL_ES_VERSION_3_2")); Assert.AreEqual(new KhronosVersion(2, 0, KhronosVersion.ApiGlsc2), KhronosVersion.ParseFeature("GL_SC_VERSION_2_0")); }
private static bool IsCompatible_RemovedAttribute(RegistryAssemblyConfiguration cfg, CustomAttribute customAttrib) { string featureName = customAttrib.ConstructorArguments[0].Value as string; KhronosVersion attribVersion = KhronosVersion.ParseFeature(featureName, false); if (attribVersion != null) { foreach (RegistryAssemblyConfiguration.VersionRange cfgFeature in cfg.Features) { if (cfgFeature.Api != null && cfgFeature.Api == attribVersion.Api) { return(false); } } } return(true); }