TypeDescriptionProvider.GetCache(Object) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a per-object cache, accessed as an IDictionary of key/value pairs.
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
The object for which to get the cache.
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.
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: