Open sandboxFocus

Class DependencyAttribute

Custom attribute that, when applied to a field or automatic property in user code, means that this field or property is a service dependency that must be pulled from the dependency injection framework. Contrarily to IntroduceDependencyAttribute that must be used in aspect code, this attribute must be used in user code.

Inheritance
DependencyAttribute
Namespace: Metalama.Extensions.DependencyInjection
Assembly: Metalama.Extensions.DependencyInjection.dll
Syntax
public class DependencyAttribute : FieldOrPropertyAspect, IAspect<IFieldOrProperty>, IAspect, ICompileTimeSerializable, ITemplateProvider, IEligible<IFieldOrProperty>
Remarks

The implementation of this custom attribute depends on the selected dependency injection framework.

Constructors

Name Description
DependencyAttribute()

Properties

Name Description
IsLazy

Gets or sets a value indicating whether the dependency should be pulled from the container lazily, i.e. upon first use.

IsRequired

Gets or sets a value indicating whether the dependency is required.

Methods

Name Description
BuildAspect(IAspectBuilder<IFieldOrProperty>)

Initializes the aspect. The implementation must add advice, child aspects and validators using the builder parameter.

ToProperties(IFieldOrProperty)

Extension Methods