Metalama 1.0 / / Metalama Documentation / Aspect API / Metalama.​Framework.​Aspects / IAspect­Receiver<TDeclaration>

Interface IAspectReceiver<TDeclaration>

Represents a set of declarations and offers the ability to add aspects, annotations to them. It inherits from IValidatorReceiver<TDeclaration>, which allows to add validators.

Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public interface IAspectReceiver<out TDeclaration> : IValidatorReceiver<TDeclaration>, IValidatorReceiver where TDeclaration : class, IDeclaration
Type Parameters
Name Description
TDeclaration

Methods

Name Description
AddAspect(Type, Func<TDeclaration, IAspect>)

Adds a aspect to the current set of declarations or throws an exception if the aspect is not eligible for the aspect. This overload is non-generic.

AddAspect<TAspect>()

Adds an aspect to the current set of declarations or throws an exception if the aspect is not eligible for the aspect. This overload creates a new instance of the aspect class for each target declaration.

AddAspect<TAspect>(Func<TDeclaration, TAspect>)

Adds an aspect to the current set of declarations or throws an exception if the aspect is not eligible for the aspect.

AddAspectIfEligible(Type, Func<TDeclaration, IAspect>, EligibleScenarios)

Adds an aspect to the current set of declarations but only if the aspect is eligible for the declaration. This overload is non-generic.

AddAspectIfEligible<TAspect>(EligibleScenarios)

Adds an aspect to the current set of declarations using the default constructor of the aspect type. This method does not verify the eligibility of the declaration for the aspect unless you specify the eligibility parameter. This overload creates a new instance of the aspect class for each eligible target declaration.

AddAspectIfEligible<TAspect>(Func<TDeclaration, TAspect>, EligibleScenarios)

Adds an aspect to the current set of declarations but only if the aspect is eligible for the declaration.

RequireAspect<TAspect>()

Requires an instance of a specified aspect type to be present on a specified declaration. If the aspect is not present, this method adds a new instance of the aspect by using the default aspect constructor.

Select<TMember>(Func<TDeclaration, TMember>)

Selects a member or the parent of the target declaration of the current aspect or fabric with the purpose of adding aspects, annotations or validators to them using e.g. AddAspectIfEligible<TAspect>(EligibleScenarios). Validate(ValidatorDelegate<DeclarationValidationContext>) or ValidateReferences(ValidatorDelegate<ReferenceValidationContext>, ReferenceKinds).

SelectMany<TMember>(Func<TDeclaration, IEnumerable<TMember>>)

Selects members of the target declaration of the current aspect or fabric with the purpose of adding aspects, annotations or validators to them using e.g. AddAspectIfEligible<TAspect>(EligibleScenarios), Validate(ValidatorDelegate<DeclarationValidationContext>) or ValidateReferences(ValidatorDelegate<ReferenceValidationContext>, ReferenceKinds).

Where(Func<TDeclaration, Boolean>)