Class ManyObjectsResolverBase<TResolver, TResolved>
The base class for all many-objects resolvers.
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
public abstract class ManyObjectsResolverBase<TResolver, TResolved> : ResolverBase<TResolver> 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. |
Constructors
ManyObjectsResolverBase(IEnumerable<Type>, ObjectLifetimeScope)
Declaration
[Obsolete("Use ctor specifying IServiceProvider instead")]
protected ManyObjectsResolverBase(IEnumerable<Type> value, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Type> | value | |
ObjectLifetimeScope | scope |
ManyObjectsResolverBase(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 ManyObjectsResolverBase(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. |
ManyObjectsResolverBase(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 ManyObjectsResolverBase(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 |
ManyObjectsResolverBase(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 ManyObjectsResolverBase(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. |
ManyObjectsResolverBase(HttpContextBase)
Declaration
[Obsolete("Use ctor specifying IServiceProvider instead")]
protected ManyObjectsResolverBase(HttpContextBase httpContext)
Parameters
Type | Name | Description |
---|---|---|
System.Web.HttpContextBase | httpContext |
ManyObjectsResolverBase(HttpContextBase, IEnumerable<Type>)
Initializes a new instance of the ManyObjectsResolverBase<TResolver, TResolved> class with an initial list of objects, with creation of objects based on an HttpRequest lifetime scope.
Declaration
[Obsolete("Use ctor specifying IServiceProvider instead")]
protected ManyObjectsResolverBase(HttpContextBase httpContext, IEnumerable<Type> value)
Parameters
Type | Name | Description |
---|---|---|
System.Web.HttpContextBase | httpContext | The HttpContextBase corresponding to the HttpRequest. |
System.Collections.Generic.IEnumerable<System.Type> | value | The list of object types. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | httpContext is |
ManyObjectsResolverBase(ObjectLifetimeScope)
Declaration
[Obsolete("Use ctor specifying IServiceProvider instead")]
protected ManyObjectsResolverBase(ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
Parameters
Type | Name | Description |
---|---|---|
ObjectLifetimeScope | scope |
Properties
CurrentHttpContext
Gets or sets the System.Web.HttpContextBase used to initialize this object, if any.
Declaration
protected HttpContextBase CurrentHttpContext { get; }
Property Value
Type | Description |
---|---|
System.Web.HttpContextBase |
Remarks
If not null, then LifetimeScope
will be ObjectLifetimeScope.HttpRequest
.
DefaultPluginWeight
Gets or sets the default type weight.
Declaration
protected virtual int DefaultPluginWeight { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
Determines the weight of types that do not have a WeightAttribute
set on
them, when calling GetSortedValues
.
InstanceTypes
Gets the list of types to create instances from.
Declaration
protected virtual IEnumerable<Type> InstanceTypes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Type> |
LifetimeScope
Gets or sets the lifetime scope of resolved objects.
Declaration
protected ObjectLifetimeScope LifetimeScope { get; }
Property Value
Type | Description |
---|---|
ObjectLifetimeScope |
Logger
Declaration
public ILogger Logger { get; }
Property Value
Type | Description |
---|---|
ILogger |
ServiceProvider
Returns the service provider used to instantiate objects
Declaration
public IServiceProvider ServiceProvider { get; }
Property Value
Type | Description |
---|---|
System.IServiceProvider |
SupportsAdd
Gets a value indicating whether the resolver supports adding types.
Declaration
protected virtual bool SupportsAdd { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
SupportsClear
Gets a value indicating whether the resolver supports clearing types.
Declaration
protected virtual bool SupportsClear { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
SupportsInsert
Gets a value indicating whether the resolver supports inserting types.
Declaration
protected virtual bool SupportsInsert { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
SupportsRemove
Gets a value indicating whether the resolver supports removing types.
Declaration
protected virtual bool SupportsRemove { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Values
Gets the resolved object instances.
Declaration
protected IEnumerable<TResolved> Values { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TResolved> |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException |
|
Methods
AddType(Type)
Adds a type.
Declaration
public virtual void AddType(Type value)
Parameters
Type | Name | Description |
---|---|---|
System.Type | value | The type to add. |
Remarks
The type is appended at the end of the list.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | the resolver does not support adding types, or the type is not a valid type for the resolver, or the type is already in the collection of types. |
AddType<T>()
Adds a type.
Declaration
public void AddType<T>()where T : TResolved
Type Parameters
Name | Description |
---|---|
T | The type to add. |
Remarks
The type is appended at the end of the list.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | the resolver does not support adding types, or the type is not a valid type for the resolver, or the type is already in the collection of types. |
AddTypes(IEnumerable<Type>)
Adds types.
Declaration
protected void AddTypes(IEnumerable<Type> types)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Type> | types | The types to add. |
Remarks
The types are appended at the end of the list.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | the resolver does not support adding types, or a type is not a valid type for the resolver, or a type is already in the collection of types. |
Clear()
Clears the list of types
Declaration
public virtual void Clear()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | the resolver does not support clearing types. |
ContainsType(Type)
Returns a value indicating whether the specified type is already in the collection of types.
Declaration
public virtual bool ContainsType(Type value)
Parameters
Type | Name | Description |
---|---|---|
System.Type | value | The type to look for. |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether the type is already in the collection of types. |
ContainsType<T>()
Returns a value indicating whether the specified type is already in the collection of types.
Declaration
public bool ContainsType<T>()where T : TResolved
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether the type is already in the collection of types. |
Type Parameters
Name | Description |
---|---|
T | The type to look for. |
CreateInstances()
Creates the object instances for the types contained in the types collection.
Declaration
protected virtual IEnumerable<TResolved> CreateInstances()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TResolved> | A list of objects of type TResolved. |
EnsureCorrectType(Type)
Ensures that a type is a valid type for the resolver.
Declaration
protected virtual void EnsureCorrectType(Type value)
Parameters
Type | Name | Description |
---|---|---|
System.Type | value | The type to test. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | the type is not a valid type for the resolver. |
EnsureSupportsAdd()
Ensures that the resolver supports adding types.
Declaration
protected void EnsureSupportsAdd()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The resolver does not support adding types. |
EnsureSupportsClear()
Ensures that the resolver supports clearing types.
Declaration
protected void EnsureSupportsClear()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The resolver does not support clearing types. |
EnsureSupportsInsert()
Ensures that the resolver supports inserting types.
Declaration
protected void EnsureSupportsInsert()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The resolver does not support inserting types. |
EnsureSupportsRemove()
Ensures that the resolver supports removing types.
Declaration
protected void EnsureSupportsRemove()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The resolver does not support removing types. |
GetObjectWeight(Object)
Returns the weight of an object for user with GetSortedValues
Declaration
protected virtual int GetObjectWeight(object o)
Parameters
Type | Name | Description |
---|---|---|
System.Object | o |
Returns
Type | Description |
---|---|
System.Int32 |
GetSortedValues()
Gets the resolved object instances, sorted by weight.
Declaration
protected IEnumerable<TResolved> GetSortedValues()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TResolved> | The sorted resolved object instances. |
Remarks
The order is based upon the WeightAttribute
and DefaultPluginWeight
.
Weights are sorted ascendingly (lowest weights come first).
GetTypes()
Gets the types in the collection of types.
Declaration
public virtual IEnumerable<Type> GetTypes()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Type> | The types in the collection of types. |
Remarks
Returns an enumeration, the list cannot be modified.
GetWriteLock()
Returns a WriteLock to use when modifying collections
Declaration
protected WriteLock GetWriteLock()
Returns
Type | Description |
---|---|
WriteLock |
InsertType(Int32, Type)
Inserts a type at the specified index.
Declaration
public virtual void InsertType(int index, Type value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index at which the type should be inserted. |
System.Type | value | The type to insert. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | the resolver does not support inserting types, or the type is not a valid type for the resolver, or the type is already in the collection of types. |
System.ArgumentOutOfRangeException | index is out of range. |
InsertType(Type)
Inserts a type at the beginning of the list.
Declaration
public virtual void InsertType(Type value)
Parameters
Type | Name | Description |
---|---|---|
System.Type | value | The type to insert. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | the resolver does not support inserting types, or the type is not a valid type for the resolver, or the type is already in the collection of types. |
InsertType<T>()
Inserts a type at the beginning of the list.
Declaration
public void InsertType<T>()where T : TResolved
Type Parameters
Name | Description |
---|---|
T | The type to insert. |
InsertType<T>(Int32)
Inserts a type at the specified index.
Declaration
public void InsertType<T>(int index)where T : TResolved
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index at which the type should be inserted. |
Type Parameters
Name | Description |
---|---|
T | The type to insert. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | index is out of range. |
InsertTypeBefore(Type, Type)
Inserts a type before a specified, already existing type.
Declaration
public virtual void InsertTypeBefore(Type existingType, Type value)
Parameters
Type | Name | Description |
---|---|---|
System.Type | existingType | The existing type before which to insert. |
System.Type | value | The type to insert. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | the resolver does not support inserting types, or one of the types is not a valid type for the resolver, or the existing type is not in the collection, or the new type is already in the collection of types. |
InsertTypeBefore<TExisting, T>()
Inserts a type before a specified, already existing type.
Declaration
public void InsertTypeBefore<TExisting, T>()where TExisting : TResolved where T : TResolved
Type Parameters
Name | Description |
---|---|
TExisting | The existing type before which to insert. |
T | The type to insert. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | the resolver does not support inserting types, or one of the types is not a valid type for the resolver, or the existing type is not in the collection, or the new type is already in the collection of types. |
RemoveType(Type)
Removes a type.
Declaration
public virtual void RemoveType(Type value)
Parameters
Type | Name | Description |
---|---|---|
System.Type | value | The type to remove. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | the resolver does not support removing types, or the type is not a valid type for the resolver. |
RemoveType<T>()
Removes a type.
Declaration
public void RemoveType<T>()where T : TResolved
Type Parameters
Name | Description |
---|---|
T | The type to remove. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | the resolver does not support removing types, or the type is not a valid type for the resolver. |