Applies to: Umbraco 4.10.0+
A Resolver is an class that returns a plugin object or multiple plugin objects. There are 2 types of Resolvers: A single object resolver and a multiple object resolver.
Single object resolver
A resolver that returns a single object. The best way to explain this is by example:
IContentStore routesCache = ContentStoreResolver.Current.ContentStore;
In the example above we get the currently assigned IContentStore from the ContentStoreResolver. This is a single object registered resolver and therefore it only returns one object. Developers can register a custom object in single object resolvers so long as the resolver is created to allow this.
As an example, to set a different IContentStore, we would execute this code:
All single object resolvers return an object that will exist as a singleton and one instance will exist for the lifetime of the application.
Multiple object resolver
A resolver that returns multiple objects of one type. Again, an example works best to explain:
IEnumerable<ICacheRefresher> cacheRefreshers = CacheRefreshersResolver.Current.CacheResolvers;
In the example above we get all ICacheRefresher object that have been found and/or registered. As this is a multiple object resolver, it returns many objects. Developers can modify the list of types in a multiple object resolver during application startup. For example to add a custom cache refresher of type 'CustomCacheRefresher' the following code can be executed:
Some multiple object resolvers need to maintain a specific order of objects such as the DocumentLookupsResolver. Developers have full control over the order of registered objects since the base class
Umbraco.Core.ObjectResolution.ManyObjectsResolverBase supports multiple methods like a list:
void RemoveType(Type value)
void AddType(Type value)
void InsertType(int index, Type value)
void InsertType<T>(int index)
Multiple object resolvers can return instances based on different lifetime scopes. The lifetime scope of a resolver is determined by the developer of the resolver.