Open sandboxFocus

Method TryGetDeclaration

TryGetDeclaration<T>(IIntroductionAdviceResult<T>, out T?)

Attempts to get the declaration (method, property, field, event, type, or operator) that was introduced by the advice, if the advice was successful.

Declaration
public static bool TryGetDeclaration<T>(this IIntroductionAdviceResult<T> adviceResult, out T? declaration) where T : class, IDeclaration
Parameters
Type Name Description
IIntroductionAdviceResult<T> adviceResult

The advice result to check.

T declaration

When this method returns true, contains the introduced or overridden declaration; otherwise, null.

Returns
Type Description
bool

true if the advice successfully introduced or overrode a declaration (outcomes: Default, Override, or New); otherwise, false.

Type Parameters
Name Description
T

The type of declaration (e.g., IMethod, IProperty, IField, IEvent, INamedType).

Remarks

When the introduced declaration is a type, the IIntroductionAdviceResult<T> interface itself implements IAdviser<T> and can be used to introduce members to the type.