private VersionCheckOutcome CheckVersion([NotNull] Version platformVersion, [NotNull] Assembly assembly) { VersionCheckOutcome result = VersionCheckOutcome.NotAnExtensionLibrary; var attributes = CustomAttributeData.GetCustomAttributes(assembly); if (attributes.Any()) { var typeName = typeof(ExtensionsContainerAttribute).FullName; { foreach (var attribute in attributes) { if (string.CompareOrdinal(attribute.AttributeType.FullName, typeName) == 0) { result = VersionCheckOutcome.DoesNotSupportCurrentEngine; ExtensionsContainerAttribute attrib = null; switch (attribute.ConstructorArguments.Count) { case 1: attrib = new ExtensionsContainerAttribute((string)attribute.ConstructorArguments[0].Value); break; case 2: if (attribute.ConstructorArguments[1].ArgumentType == typeof(string)) { attrib = new ExtensionsContainerAttribute( (string)attribute.ConstructorArguments[0].Value, (string)attribute.ConstructorArguments[1].Value); } else { attrib = new ExtensionsContainerAttribute( (string)attribute.ConstructorArguments[0].Value, (uint)attribute.ConstructorArguments[1].Value); } break; case 3: attrib = new ExtensionsContainerAttribute( (string)attribute.ConstructorArguments[0].Value, (string)attribute.ConstructorArguments[1].Value, (uint)attribute.ConstructorArguments[2].Value); break; } if (attrib?.IsApplicableExtensionsContainer(platformVersion) ?? false) { result = VersionCheckOutcome.Ok; break; } } } } } return(result); }
private bool CheckVersion([NotNull] Version platformVersion, [NotNull] Assembly assembly) { bool result = false; var attributes = CustomAttributeData.GetCustomAttributes(assembly); if (attributes.Any()) { var typeName = typeof(ExtensionsContainerAttribute).FullName; { foreach (var attribute in attributes) { if (string.CompareOrdinal(attribute.AttributeType.FullName, typeName) == 0) { ExtensionsContainerAttribute attrib = null; switch (attribute.ConstructorArguments.Count) { case 1: attrib = new ExtensionsContainerAttribute(attribute.ConstructorArguments[0].Value.ToString()); break; case 2: attrib = new ExtensionsContainerAttribute(attribute.ConstructorArguments[0].Value.ToString(), attribute.ConstructorArguments[1].ToString()); break; } if (attrib?.IsApplicableExtensionsContainer(platformVersion) ?? false) { result = true; break; } } } } } return(result); }