Open sandboxFocus

Method ImplementInterface

ImplementInterface(IAdviser<INamedType>, INamedType, OverrideStrategy, object?)

Makes a type implement a new interface specified as an INamedType. Interface members can be introduced declaratively by marking an aspect member by InterfaceMemberAttribute or Use the With<TNewDeclaration>(TNewDeclaration) method to apply the advice to another declaration than the current one. IntroduceAttribute(IAdviser<IDeclaration>, IAttributeData, OverrideStrategy), or programmatically using Introduce methods for public implementations of result.ExplicitImplementations.Introduce for private implementations.

Declaration
public static IImplementInterfaceAdviceResult ImplementInterface(this IAdviser<INamedType> adviser, INamedType interfaceType, OverrideStrategy whenExists = OverrideStrategy.Default, object? tags = null)
Parameters
Type Name Description
IAdviser<INamedType> adviser

An adviser for a named type.

INamedType interfaceType

The type of the implemented interface.

OverrideStrategy whenExists

Determines the implementation strategy when the interface is already implemented by the target type. The default strategy is to fail with a compile-time error.

object tags

An optional opaque object of anonymous type passed to InterfaceMemberAttribute templates and exposed under the Tags property of the meta API. This parameter does not affect members introduced using IntroduceAttribute(IAdviser<IDeclaration>, IAttributeData, OverrideStrategy) or programmatically.

Returns
Type Description
IImplementInterfaceAdviceResult
See Also

ImplementInterface(IAdviser<INamedType>, Type, OverrideStrategy, object?)

Makes a type implement a new interface specified as a reflection Type. Interface members can be introduced by marking an aspect member by InterfaceMemberAttribute, IntroduceAttribute(IAdviser<IDeclaration>, IAttributeData, OverrideStrategy) or programmatically using Introduce methods. Use the With<TNewDeclaration>(TNewDeclaration) method to apply the advice to another declaration than the current one.

Declaration
public static IImplementInterfaceAdviceResult ImplementInterface(this IAdviser<INamedType> adviser, Type interfaceType, OverrideStrategy whenExists = OverrideStrategy.Default, object? tags = null)
Parameters
Type Name Description
IAdviser<INamedType> adviser

An adviser for a named type.

Type interfaceType

The type of the implemented interface.

OverrideStrategy whenExists

Determines the implementation strategy when the interface is already implemented by the target type. The default strategy is to fail with a compile-time error.

object tags

An optional opaque object of anonymous type passed to InterfaceMemberAttribute templates and exposed under the Tags property of the meta API. This parameter does not affect members introduced using IntroduceAttribute(IAdviser<IDeclaration>, IAttributeData, OverrideStrategy) or programmatically.

Returns
Type Description
IImplementInterfaceAdviceResult
See Also