MetalamaAPI documentationAspect APIMetalama.​Framework.​AspectsIAspect­Receiver<TDeclaration>Add­Aspect
Open sandboxFocus

IAspectReceiver<TDeclaration>.AddAspect Method

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.

Declaration
void AddAspect(Type aspectType, Func<TDeclaration, IAspect> createAspect)
Parameters
Type Name Description
System.Type aspectType

The exact type of the aspect returned by createAspect. It is not allowed to specify a base type in this parameter, only the exact type.

System.Func<TDeclaration, IAspect> createAspect

A function that returns the aspect for a given 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.

Declaration
void AddAspect<TAspect>(Func<TDeclaration, TAspect> createAspect)
where TAspect : class, IAspect<TDeclaration>
Parameters
Type Name Description
System.Func<TDeclaration, TAspect> createAspect

A function that returns the aspect for a given declaration.

Type Parameters
Name Description
TAspect

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.

Declaration
void AddAspect<TAspect>()
where TAspect : class, IAspect<TDeclaration>, new()
Type Parameters
Name Description
TAspect