ValidationContext.GetCache Method

Include Protected Members
Include Inherited Members

Gets the cache for the specified class.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

Overload List

  Name Description
Public method GetCache<T>() Gets the cache for the specified class.
Public method GetCache<T>(String) Gets the cache for the specified class.

Top

Remarks

You should use this method to avoid caching information in variables.

The method gets the class cache that is associated with the validation context. When this method is called for the first time, a cache is created for the class. Each additional time this method is called, the existing cache is retrieved. A cache is created for each parameter class and can be called from other classes.

To use this method, the target class must have a zero-parameter constructor. Composite classes are also allowed. For example, you could use: context.GetCache<Dictionary<string, extraObject>>()

After the cache is returned, you can use it with the ValidationMessageObserver class, which enables you to pass information between validation methods.

See Also

Reference

ValidationContext Class

Microsoft.VisualStudio.Modeling.Validation Namespace