Open sandboxFocus

Class IntroduceDependencyAttribute

Custom attribute that, when be applied to a field or automatic property of an aspect, means that this field or property is a service dependency that introduced into the target type and handled by a dependency injection framework. Contrarily to DependencyAttribute that can be used in user code, this attribute can be used only in an aspect.

Inheritance
IntroduceDependencyAttribute
Implements
Namespace: Metalama.Extensions.DependencyInjection
Assembly: Metalama.Extensions.DependencyInjection.dll
Syntax
public class IntroduceDependencyAttribute : DeclarativeAdviceAttribute, IAdviceAttribute
Remarks

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

Constructors

Name Description
IntroduceDependencyAttribute()

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
BuildAdvice(IMemberOrNamedType, string, IAspectBuilder<IDeclaration>)

Builds the aspect, i.e. translates the current declarative advice into a programmatic advice or possibly diagnostics and validators. In case of error, the implementation must report diagnostics and call SkipAspect().

ToProperties(IFieldOrProperty, INamedType)