November Happy Hour will be moved to Thursday December 5th.

Class Injected<T>

Marks a property for property injection by the IoC container. When a class uses properties of this type is constructed via the IoC container or BuildUp is called properties of this type are injected by the system. For objects constructed maually via new the service is located using the global service locator object.

Inheritance
System.Object
Injected<T>
Namespace: EPiServer.ServiceLocation
Assembly: EPiServer.Framework.dll
Version: 12.0.3
Syntax
public sealed class Injected<T> : ValueType where T : class
Type Parameters
Name Description
T

The type of service to inject.

Constructors

Injected(T)

Initializes an instance with a specific service accessor.

Declaration
public Injected(T service)
Parameters
Type Name Description
T service

The service instance to use.

Injected(ServiceAccessor<T>)

Initializes an instance with a specific service accessor.

Declaration
public Injected(ServiceAccessor<T> accessor)
Parameters
Type Name Description
ServiceAccessor<T> accessor

The accessor delegate to use for retrieving the service.

Properties

Accessor

Gets or sets an accessor delegate that can be used to retrieve the service that should be injected.

Declaration
public ServiceAccessor<T> Accessor { get; set; }
Property Value
Type Description
ServiceAccessor<T>
Remarks

Setting this property will also affect the Service property.

Service

Gets or sets the service instance that should be injected.

Declaration
public T Service { get; set; }
Property Value
Type Description
T
Remarks

Setting this property will also affect the Accessor property.

If not set this property is lazily resolved when first used.

Operators

Implicit(T to Injected<T>)

Simplifies assignment to an injected service.

Declaration
public static implicit operator Injected<T>(T service)
Parameters
Type Name Description
T service

The service to assign.

Returns
Type Description
Injected<T>

An injected object with the service assigned.

Extension Methods