有一個名爲「Entities」的IronPython包。該軟件包包含一個定義「客戶」類和「地址」類的「Entity.py」文件。命名空間和程序集名稱如何爲IronPython類型工作?
如果我運行這個程序:
customer = Customer()
print customer.GetType().AssemblyQualifiedName
address = Address()
print address.GetType().AssemblyQualifiedName
我得到這樣的輸出:
IronPython.NewTypes.System.Object_1$1, Snippets.scripting, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
IronPython.NewTypes.System.Object_1$1, Snippets.scripting, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
是如何運作的?爲什麼兩種類型都有相同的名稱(Object_1$1
)?
我必須使用需要組件限定名稱才能創建該類型實例的API。我希望能夠以這種方式使用它:
customer = aFactory.Create("Entities.Customer, Entities");
我該怎麼做?有什麼方法可以指定名稱空間和程序集名稱?
感謝
@Dino:謝謝你的回答。我讀了你提供的鏈接。它說:「IronPython網站上提供的ClrType示例顯示瞭如何在__clrtype__鉤子之上構建。」我無法找到該示例,Google也無法找到。你能寄給我那個樣本的鏈接嗎? – Sylvain 2009-12-27 21:44:27
示例可在此處找到:http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=12482#DownloadId=96609 – 2009-12-28 20:01:30
@迪諾:謝謝,我會檢查一下。 – Sylvain 2009-12-29 15:31:02