0
我想製作一個採用TypeDefinition並告訴我它是否代表COM對象的方法。 該方法也應該在.NET 4.0「嵌入式COM互操作類型」的情況下工作。MonoCecil Type.IsCOMObject等效嗎?
任何想法我可以做到這一點?
我想製作一個採用TypeDefinition並告訴我它是否代表COM對象的方法。 該方法也應該在.NET 4.0「嵌入式COM互操作類型」的情況下工作。MonoCecil Type.IsCOMObject等效嗎?
任何想法我可以做到這一點?
也許是這樣的:
public static bool IsCOMObject(TypeDefinition type)
{
if (type == null)
throw new ArgumentNullException("type");
return (type.Attributes & TypeAttributes.Import) == TypeAttributes.Import;
}
從這裏正式參考:Common Language Infrastructure (CLI). Partition II: Metadata Definition and Semantics。
10.1 Type頭(ClassHeader):
實現特定的(微軟)
上述語法還包括 ClassAttr :: =進口以指示 類型是從COM類型進口 庫。
我測試了它,這對.NET 4.0「Embedded COM Interop Types」和常規PIA COM類型都有效。謝謝!! – 2011-04-24 17:19:05