MetalamaAPI documentationAspect APIMetalama.​Framework.​AspectsContract­AspectRedirect­Contracts
Open sandboxFocus

ContractAspect.RedirectContracts Method

RedirectContracts(IAspectBuilder, IFieldOrPropertyOrIndexer, IParameter)

Redirects validation logic of ContractAspect from the specified property to the specified parameter.

Declaration
public static void RedirectContracts(IAspectBuilder aspectBuilder, IFieldOrPropertyOrIndexer sourceTarget, IParameter targetParameter)
Parameters
Type Name Description
IAspectBuilder aspectBuilder

Current aspect builder.

IFieldOrPropertyOrIndexer sourceTarget

A declaration to redirect the validation logic from.

IParameter targetParameter

A parameter to redirect the validation logic to.

Remarks

This call will only redirect validation logic of contracts applied after the current aspect. Contracts applied before the current aspect will not be affected.

If an aspect needs to see the contract aspect instances and redirect their validation logic at the same time, it should be applied after the default layer of ContractAspect and before the layer that applies the contract logic, i.e. BuildLayer.