Export (0) Print
Expand All

TypeDescriptionProvider.GetCache Method

Gets a per-object cache, accessed as an IDictionary of key/value pairs.

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

public virtual IDictionary GetCache(
	Object instance
)

Parameters

instance
Type: System.Object

The object for which to get the cache.

Return Value

Type: System.Collections.IDictionary
An IDictionary if the provided object supports caching; otherwise, null.

A TypeDescriptor may need to perform complex operations on collections of metadata. Because types are not unloaded for the life of a domain, the TypeDescriptor class will automatically cache the results of these operations based on type. However, some operations use live object instances. These operations cannot be cached within the TypeDescriptor class because caching them would prevent the object from being garbage collected. Instead, the TypeDescriptor class allows for a per-object cache, accessed as an IDictionary of key/value pairs, to exist on an object. The GetCache method returns an instance of this cache. The GetCache method will return null if there is no supported cache for an object.

The default TypeDescriptionProvider used by TypeDescriptor examines the object to see if it is a sited component that implements the IDictionaryService interface. If the object is, it uses the dictionary service to store the object's cache. Otherwise, the object it returns null. Other type description providers may provide their own implementation here. For example, dependency objects can just attach a property of type IDictionary.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft