Class EnumerableResolutionAdapter<T>
- Namespace
- CSF.Screenplay
- Assembly
- CSF.Screenplay.ReqnrollPlugin.dll
Adapter class which - when added to DI - permits the BoDi DI container to resolve arbitrary IEnumerable<T> of service instances.
public class EnumerableResolutionAdapter<T> : IEnumerable<T>, IEnumerable where T : class
Type Parameters
T
- Inheritance
-
EnumerableResolutionAdapter<T>
- Implements
-
IEnumerable<T>
- Inherited Members
Remarks
The BoDi DI container which is included in Reqnroll/SpecFlow does not fully support the functionality of Microsoft's DI standard. Notably, it cannot natively resolve an IEnumerable<T>, where type T is a service type which may have multiple implementations added to/registered with the container. BoDi does have conceptually identical functionality, in its ResolveAll<T>() function.
The purpose of this type is to provide a mechanism by which BoDi may resolve enumerables of service types. This class wraps an instance of IObjectContainer and - in its GetEnumerator() method - redirects to the ResolveAll<T>() method.
The limitation of this type (as a workaround) is that this type must be added to the container manually for each IEnumerable<T> type which could be resolved from the container.
Constructors
EnumerableResolutionAdapter(IObjectContainer)
Initializes a new instance of EnumerableResolutionAdapter<T>.
public EnumerableResolutionAdapter(IObjectContainer container)
Parameters
containerIObjectContainerThe BoDi object container.
Exceptions
- ArgumentNullException
containerisnull.
Methods
GetEnumerator()
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>