TypeDescriptionProvider.GetCache(Object) 方法

定義

取得個別物件的快取,以索引鍵/值組的 IDictionary 方式存取。

public:
 virtual System::Collections::IDictionary ^ GetCache(System::Object ^ instance);
public virtual System.Collections.IDictionary GetCache (object instance);
public virtual System.Collections.IDictionary? GetCache (object instance);
abstract member GetCache : obj -> System.Collections.IDictionary
override this.GetCache : obj -> System.Collections.IDictionary
Public Overridable Function GetCache (instance As Object) As IDictionary

參數

instance
Object

要為其取得快取的物件。

傳回

如果提供的物件支援快取,則為 IDictionary,否則為 null

備註

TypeDescriptor可能需要對元數據集合執行複雜的作業。 由於類型不會在定義域的生命週期中卸除類型,因此類別 TypeDescriptor 會自動根據類型快取這些作業的結果。 不過,某些作業會使用即時對象實例。 無法快 TypeDescriptor 取類別內的這些作業,因為快取作業會防止物件被垃圾收集。 相反地,類別 TypeDescriptor 允許以索引鍵/值組的形式存取 IDictionary 的每個物件快取存在於物件上。 方法會 GetCache 傳回這個快取的實例。 如果物件沒有支援的快取,方法 GetCache 會傳回 null

所使用的TypeDescriptor預設值TypeDescriptionProvider會檢查 物件,以查看它是實作 IDictionaryService 介面的月臺元件。 如果物件是 ,它會使用字典服務來儲存物件的快取。 否則,它會傳 null回 的物件。 其他類型描述提供者可能會在這裡提供自己的實作。 例如,相依性物件只能附加 類型的 IDictionary屬性。

適用於

另請參閱