Class LazyManyObjectsResolverBase<TResolver, TResolved>
The base class for all lazy many-objects resolvers.
Inheritance
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
public abstract class LazyManyObjectsResolverBase<TResolver, TResolved> : ManyObjectsResolverBase<TResolver, TResolved> where TResolver : ResolverBase where TResolved : class
Type Parameters
Name | Description |
---|---|
TResolver | The type of the concrete resolver class. |
TResolved | The type of the resolved objects. |
Remarks
This is a special case resolver for when types get lazily resolved in order to resolve the actual types. This is useful for when there is some processing overhead (i.e. Type finding in assemblies) to return the Types used to instantiate the instances. In some these cases we don't want to have to type-find during application startup, only when we need to resolve the instances.
Important notes about this resolver: it does not support Insert or Remove and therefore does not support any ordering unless the types are marked with the WeightAttribute.
Constructors
LazyManyObjectsResolverBase(IEnumerable<Lazy<Type>>, ObjectLifetimeScope)
Declaration
[Obsolete("Use ctor specifying IServiceProvider instead")]
protected LazyManyObjectsResolverBase(IEnumerable<Lazy<Type>> lazyTypeList, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Lazy<System.Type>> | lazyTypeList | |
ObjectLifetimeScope | scope |
LazyManyObjectsResolverBase(Func<IEnumerable<Type>>, ObjectLifetimeScope)
Declaration
[Obsolete("Use ctor specifying IServiceProvider instead")]
protected LazyManyObjectsResolverBase(Func<IEnumerable<Type>> typeListProducerList, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Collections.Generic.IEnumerable<System.Type>> | typeListProducerList | |
ObjectLifetimeScope | scope |
LazyManyObjectsResolverBase(IServiceProvider, ILogger, IEnumerable<Lazy<Type>>, ObjectLifetimeScope)
Declaration
protected LazyManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, IEnumerable<Lazy<Type>> lazyTypeList, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
Parameters
Type | Name | Description |
---|---|---|
System.IServiceProvider | serviceProvider | |
ILogger | logger | |
System.Collections.Generic.IEnumerable<System.Lazy<System.Type>> | lazyTypeList | |
ObjectLifetimeScope | scope |
LazyManyObjectsResolverBase(IServiceProvider, ILogger, IEnumerable<Type>, ObjectLifetimeScope)
Initializes a new instance of the ManyObjectsResolverBase<TResolver, TResolved> class with an initial list of object types, and an optional lifetime scope.
Declaration
protected LazyManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, IEnumerable<Type> value, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
Parameters
Type | Name | Description |
---|---|---|
System.IServiceProvider | serviceProvider | |
ILogger | logger | |
System.Collections.Generic.IEnumerable<System.Type> | value | The list of object types. |
ObjectLifetimeScope | scope | The lifetime scope of instantiated objects, default is per Application. |
Remarks
If scope is per HttpRequest then there must be a current HttpContext.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | scope is per HttpRequest but the current HttpContext is null. |
LazyManyObjectsResolverBase(IServiceProvider, ILogger, Func<IEnumerable<Type>>, ObjectLifetimeScope)
Declaration
protected LazyManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, Func<IEnumerable<Type>> typeListProducerList, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
Parameters
Type | Name | Description |
---|---|---|
System.IServiceProvider | serviceProvider | |
ILogger | logger | |
System.Func<System.Collections.Generic.IEnumerable<System.Type>> | typeListProducerList | |
ObjectLifetimeScope | scope |
LazyManyObjectsResolverBase(IServiceProvider, ILogger, HttpContextBase)
Initializes a new instance of the ManyObjectsResolverBase<TResolver, TResolved> class with an empty list of objects, with creation of objects based on an HttpRequest lifetime scope.
Declaration
protected LazyManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, HttpContextBase httpContext)
Parameters
Type | Name | Description |
---|---|---|
System.IServiceProvider | serviceProvider | |
ILogger | logger | |
System.Web.HttpContextBase | httpContext | The HttpContextBase corresponding to the HttpRequest. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | httpContext is |
LazyManyObjectsResolverBase(IServiceProvider, ILogger, HttpContextBase, IEnumerable<Lazy<Type>>)
Declaration
protected LazyManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, HttpContextBase httpContext, IEnumerable<Lazy<Type>> lazyTypeList)
Parameters
Type | Name | Description |
---|---|---|
System.IServiceProvider | serviceProvider | |
ILogger | logger | |
System.Web.HttpContextBase | httpContext | |
System.Collections.Generic.IEnumerable<System.Lazy<System.Type>> | lazyTypeList |
LazyManyObjectsResolverBase(IServiceProvider, ILogger, HttpContextBase, Func<IEnumerable<Type>>)
Declaration
protected LazyManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, HttpContextBase httpContext, Func<IEnumerable<Type>> typeListProducerList)
Parameters
Type | Name | Description |
---|---|---|
System.IServiceProvider | serviceProvider | |
ILogger | logger | |
System.Web.HttpContextBase | httpContext | |
System.Func<System.Collections.Generic.IEnumerable<System.Type>> | typeListProducerList |
LazyManyObjectsResolverBase(IServiceProvider, ILogger, ObjectLifetimeScope)
Initializes a new instance of the ManyObjectsResolverBase<TResolver, TResolved> class with an empty list of objects, and an optional lifetime scope.
Declaration
protected LazyManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
Parameters
Type | Name | Description |
---|---|---|
System.IServiceProvider | serviceProvider | |
ILogger | logger | |
ObjectLifetimeScope | scope | The lifetime scope of instantiated objects, default is per Application. |
Remarks
If scope is per HttpRequest then there must be a current HttpContext.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | scope is per HttpRequest but the current HttpContext is null. |
LazyManyObjectsResolverBase(HttpContextBase)
Declaration
[Obsolete("Use ctor specifying IServiceProvider instead")]
protected LazyManyObjectsResolverBase(HttpContextBase httpContext)
Parameters
Type | Name | Description |
---|---|---|
System.Web.HttpContextBase | httpContext |
LazyManyObjectsResolverBase(HttpContextBase, IEnumerable<Lazy<Type>>)
Declaration
[Obsolete("Use ctor specifying IServiceProvider instead")]
protected LazyManyObjectsResolverBase(HttpContextBase httpContext, IEnumerable<Lazy<Type>> lazyTypeList)
Parameters
Type | Name | Description |
---|---|---|
System.Web.HttpContextBase | httpContext | |
System.Collections.Generic.IEnumerable<System.Lazy<System.Type>> | lazyTypeList |
LazyManyObjectsResolverBase(HttpContextBase, Func<IEnumerable<Type>>)
Declaration
[Obsolete("Use ctor specifying IServiceProvider instead")]
protected LazyManyObjectsResolverBase(HttpContextBase httpContext, Func<IEnumerable<Type>> typeListProducerList)
Parameters
Type | Name | Description |
---|---|---|
System.Web.HttpContextBase | httpContext | |
System.Func<System.Collections.Generic.IEnumerable<System.Type>> | typeListProducerList |
LazyManyObjectsResolverBase(ObjectLifetimeScope)
Declaration
[Obsolete("Use ctor specifying IServiceProvider instead")]
protected LazyManyObjectsResolverBase(ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
Parameters
Type | Name | Description |
---|---|---|
ObjectLifetimeScope | scope |
Properties
HasResolvedTypes
Gets a value indicating whether the resolver has resolved types to create instances from.
Declaration
public bool HasResolvedTypes { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
To be used in unit tests.
InstanceTypes
Gets the list of types to create instances from.
Declaration
protected override IEnumerable<Type> InstanceTypes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Type> |
Remarks
When called, will get the types from the lazy list.
SupportsInsert
Gets a false
value indicating that the resolver does NOT support inserting types.
Declaration
protected override bool SupportsInsert { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
AddType(Lazy<Type>)
Lazily adds a type from a lazy type.
Declaration
public void AddType(Lazy<Type> value)
Parameters
Type | Name | Description |
---|---|---|
System.Lazy<System.Type> | value | The lazy type, to add. |
AddType(Type)
Lazily adds a type from an actual type.
Declaration
public override void AddType(Type value)
Parameters
Type | Name | Description |
---|---|---|
System.Type | value | The actual type, to add. |
Remarks
The type is converted to a lazy type.
AddTypeListDelegate(Func<IEnumerable<Type>>)
Lazily adds types from a function producing types.
Declaration
public void AddTypeListDelegate(Func<IEnumerable<Type>> typeListProducer)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Collections.Generic.IEnumerable<System.Type>> | typeListProducer | The functions producing types, to add. |
AddTypes(IEnumerable<Lazy<Type>>)
Lazily adds types from lazy types.
Declaration
protected void AddTypes(IEnumerable<Lazy<Type>> types)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Lazy<System.Type>> | types | The lazy types, to add. |
Clear()
Clears all lazy types
Declaration
public override void Clear()
RemoveType(Type)
Removes types from the list of types, once it has been lazily evaluated, and before actual objects are instanciated.
Declaration
public override void RemoveType(Type value)
Parameters
Type | Name | Description |
---|---|---|
System.Type | value | The type to remove. |