I'd like to make a method that takes a TypeDefinition and tells me if it represents a COM object. The method should also work in the .NET 4.0 "Embedded COM Interop Types" case.
Any开发者_Go百科 idea how I could do that?
Maybe something like this:
public static bool IsCOMObject(TypeDefinition type)
{
if (type == null)
throw new ArgumentNullException("type");
return (type.Attributes & TypeAttributes.Import) == TypeAttributes.Import;
}
From official reference here: Common Language Infrastructure (CLI). Partition II: Metadata Definition and Semantics.
10.1 Type header (ClassHeader):
Implementation-specific (Microsoft)
The above grammar also includes ClassAttr ::= import to indicate that the type is imported from a COM type library.
精彩评论