Class AbstractServiceEntry

Describes an abstract service entry.

Inheritance
System.Object
AbstractServiceEntry
ProducibleServiceEntry
Implements
IServiceId
Namespace: Solti.Utils.DI.Interfaces
Assembly: Solti.Utils.DI.Interfaces.dll
Syntax
public abstract class AbstractServiceEntry : Object, IServiceId
Remarks

Service entry specifies how to store, identify and instantiate a particular service.

Constructors

AbstractServiceEntry(Type, Object, Type, Expression<FactoryDelegate>, Object, ServiceOptions)

Creates a new AbstractServiceEntry instance.

Declaration
protected AbstractServiceEntry(Type type, object key, Type implementation, Expression<FactoryDelegate> factory, object explicitArgs, ServiceOptions options)
Parameters
Type Name Description
System.Type type

The type of the service.

System.Object key

The (optional) key of the service (usually a name).

System.Type implementation

The (optional) implementation of the service.

System.Linq.Expressions.Expression<FactoryDelegate> factory

The (optional) factory of the service.

System.Object explicitArgs

Optional explicit arguments (in form of {ctorArg1 = ..., ctorArg2 = ...}) to be passed to the constructor of Implementation.

ServiceOptions options

Options to be assigned to this instance.

Exceptions
Type Condition
System.ArgumentException

The implementation is not a class.

Fields

FCreateInstance

Value of CreateInterceptorDelegate property.

Declaration
protected FutureDelegate<CreateServiceDelegate> FCreateInstance
Field Value
Type Description
FutureDelegate<CreateServiceDelegate>

Properties

AssignedSlot

The assigned slot (in case of scoped services).

Declaration
public int AssignedSlot { get; protected set; }
Property Value
Type Description
System.Int32
Remarks

To assign a proper value to this property, invoke the Build(IBuildContext, IReadOnlyList<IFactoryVisitor>) method.

CreateInstance

Unconditionaly creates a new service instance.

Declaration
public CreateServiceDelegate CreateInstance { get; }
Property Value
Type Description
CreateServiceDelegate
Remarks

To assign value to this property, invoke the Build(IBuildContext, IReadOnlyList<IFactoryVisitor>) method.

Decorators

Bound decorators.

Declaration
public virtual IReadOnlyList<Expression<DecoratorDelegate>> Decorators { get; }
Property Value
Type Description
System.Collections.Generic.IReadOnlyList<System.Linq.Expressions.Expression<DecoratorDelegate>>

ExplicitArgs

Optional explicit arguments to be passed to the constructor of Implementation. It is supposed to be either a dictionary or an anonymous object:

{ctorArg1 = ..., ctorArg2 = ...}
Declaration
public object ExplicitArgs { get; }
Property Value
Type Description
System.Object

Factory

The (optional) factory of this service.

Declaration
public Expression<FactoryDelegate> Factory { get; }
Property Value
Type Description
System.Linq.Expressions.Expression<FactoryDelegate>

Features

Features related to this entry.

Declaration
public virtual ServiceEntryFeatures Features { get; }
Property Value
Type Description
ServiceEntryFeatures

Implementation

The (optional) implementation of the service.

Declaration
public Type Implementation { get; }
Property Value
Type Description
System.Type

Key

The (optional) service key (usually a name).

Declaration
public object Key { get; }
Property Value
Type Description
System.Object
Remarks

A service is identified by its Type and Key.

Lifetime

The related lifetime.

Declaration
public virtual LifetimeBase Lifetime { get; }
Property Value
Type Description
LifetimeBase

Options

Options assigned to this instance.

Declaration
public ServiceOptions Options { get; }
Property Value
Type Description
ServiceOptions

State

Current state of this entry.

Declaration
public ServiceEntryStates State { get; protected set; }
Property Value
Type Description
ServiceEntryStates

Type

The service type.

Declaration
public Type Type { get; }
Property Value
Type Description
System.Type
Remarks

A service is identified by its Type and Key.

Methods

Build(IBuildContext, IReadOnlyList<IFactoryVisitor>)

Builds this entry applying the provided factory visitors.

Declaration
public virtual void Build(IBuildContext context, IReadOnlyList<IFactoryVisitor> visitors)
Parameters
Type Name Description
IBuildContext context
System.Collections.Generic.IReadOnlyList<IFactoryVisitor> visitors

CreateLifetimeManager(Expression, ParameterExpression, ParameterExpression)

Creates the lifetime manager expression.

Declaration
public virtual Expression CreateLifetimeManager(Expression getService, ParameterExpression scope, ParameterExpression disposable)
Parameters
Type Name Description
System.Linq.Expressions.Expression getService
System.Linq.Expressions.ParameterExpression scope
System.Linq.Expressions.ParameterExpression disposable
Returns
Type Description
System.Linq.Expressions.Expression
Remarks

Lifetime manager instructs the system how to dispose a particular service instance. In most of cases it's just a simple cast:

disposable = getService() as IDisposable

Decorate(Expression<DecoratorDelegate>)

If implemented, alters the service instantiation process in order to wrap the original service into a proxy.

Declaration
public virtual void Decorate(Expression<DecoratorDelegate> decorator)
Parameters
Type Name Description
System.Linq.Expressions.Expression<DecoratorDelegate> decorator

Specialize(Type[])

Specializes a service entry if it is generic.

Declaration
public virtual AbstractServiceEntry Specialize(params Type[] genericArguments)
Parameters
Type Name Description
System.Type[] genericArguments
Returns
Type Description
AbstractServiceEntry

ToString()

Returns the short string representation of this entry.

Declaration
public override string ToString()
Returns
Type Description
System.String

ToString(Boolean)

Returns the string representation of this entry.

Declaration
public string ToString(bool shortForm)
Parameters
Type Name Description
System.Boolean shortForm
Returns
Type Description
System.String

UpdateState(ServiceEntryStates)

If supported, updates the State of this entry.

Declaration
public virtual void UpdateState(ServiceEntryStates newState)
Parameters
Type Name Description
ServiceEntryStates newState

UpdateStateInternal(ServiceEntryStates)

Provides the default implementation for the UpdateState(ServiceEntryStates) method.

Declaration
protected ServiceEntryStates UpdateStateInternal(ServiceEntryStates newState)
Parameters
Type Name Description
ServiceEntryStates newState
Returns
Type Description
ServiceEntryStates

The original state that had been updated.

Implements

IServiceId

Extension Methods

ServiceEntryAdvancedExtensions.IsInstance(AbstractServiceEntry)
ServiceEntryExtensions.IsService(AbstractServiceEntry)
ServiceEntryExtensions.IsFactory(AbstractServiceEntry)
In This Article
Back to top Generated by DocFX