Open sandboxFocus

Method AddAspectIfEligible

AddAspectIfEligible<TDeclaration>(IQuery<TDeclaration>, 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.

Declaration
public static void AddAspectIfEligible<TDeclaration>(this IQuery<TDeclaration> query, Type aspectType, Func<TDeclaration, IAspect> createAspect, EligibleScenarios eligibility = EligibleScenarios.Inheritance | EligibleScenarios.Aspect) where TDeclaration : class, IDeclaration
Parameters
Type Name Description
IQuery<TDeclaration> query

A query selecting the declarations to validate.

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.

Func<TDeclaration, IAspect> createAspect

A function that returns the aspect for a given declaration.

EligibleScenarios eligibility

The scenarios for which the aspect may be eligible. The default value is Default | Inheritance. If None is provided, eligibility is not checked.

Type Parameters
Name Description
TDeclaration

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

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

Declaration
public static void AddAspectIfEligible<TDeclaration, TAspect>(this IQuery<TDeclaration> query, Func<TDeclaration, TAspect> createAspect, EligibleScenarios eligibility = EligibleScenarios.Inheritance | EligibleScenarios.Aspect) where TDeclaration : class, IDeclaration where TAspect : class, IAspect<TDeclaration>
Parameters
Type Name Description
IQuery<TDeclaration> query

A query selecting the declarations to validate.

Func<TDeclaration, TAspect> createAspect

A function that returns the aspect for a given declaration.

EligibleScenarios eligibility

The scenarios for which the aspect may be eligible. The default value is Default | Inheritance. If None is provided, eligibility is not checked.

Type Parameters
Name Description
TDeclaration
TAspect

AddAspectIfEligible<TAspect>(IQuery<IDeclaration>, 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.

Declaration
public static void AddAspectIfEligible<TAspect>(this IQuery<IDeclaration> query, EligibleScenarios eligibility = EligibleScenarios.Inheritance | EligibleScenarios.Aspect) where TAspect : class, IAspect, new()
Parameters
Type Name Description
IQuery<IDeclaration> query

A query selecting the declarations to validate.

EligibleScenarios eligibility

The scenarios for which the aspect may be eligible. The default value is Default | Inheritance. If None is provided, eligibility is not checked.

Type Parameters
Name Description
TAspect

AddAspectIfEligible<TDeclaration, TTag>(ITaggedQuery<TDeclaration, TTag>, Type, Func<TDeclaration, TTag, 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.

Declaration
public static void AddAspectIfEligible<TDeclaration, TTag>(this ITaggedQuery<TDeclaration, TTag> query, Type aspectType, Func<TDeclaration, TTag, IAspect> createAspect, EligibleScenarios eligibility = EligibleScenarios.Inheritance | EligibleScenarios.Aspect) where TDeclaration : class, IDeclaration
Parameters
Type Name Description
ITaggedQuery<TDeclaration, TTag> query

A query selecting the declarations to validate.

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.

Func<TDeclaration, TTag, IAspect> createAspect

A function that returns the aspect for a given declaration.

EligibleScenarios eligibility

The scenarios for which the aspect may be eligible. The default value is Default | Inheritance. If None is provided, eligibility is not checked.

Type Parameters
Name Description
TDeclaration
TTag

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

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

Declaration
public static void AddAspectIfEligible<TDeclaration, TTag, TAspect>(this ITaggedQuery<TDeclaration, TTag> query, Func<TDeclaration, TTag, TAspect> createAspect, EligibleScenarios eligibility = EligibleScenarios.Inheritance | EligibleScenarios.Aspect) where TDeclaration : class, IDeclaration where TAspect : class, IAspect<TDeclaration>
Parameters
Type Name Description
ITaggedQuery<TDeclaration, TTag> query

A query selecting the declarations to validate.

Func<TDeclaration, TTag, TAspect> createAspect

A function that returns the aspect for a given declaration.

EligibleScenarios eligibility

The scenarios for which the aspect may be eligible. The default value is Default | Inheritance. If None is provided, eligibility is not checked.

Type Parameters
Name Description
TDeclaration
TTag
TAspect