Open sandboxFocus

Method IntroduceInterface

IntroduceInterface(IAdviser<INamespaceOrNamedType>, string, OverrideStrategy, Action<INamedTypeBuilder>?)

Introduces a new interface into the current namespace (as a top-level type) or type (as a nested type). Use the With<TNewDeclaration>(TNewDeclaration) or WithNamespace(IAdviser<ICompilation>, string) method to introduce the interface to a different type or namespace than the current one.

Declaration
public static IIntroductionAdviceResult<INamedType> IntroduceInterface(this IAdviser<INamespaceOrNamedType> adviser, string name, OverrideStrategy whenExists = OverrideStrategy.Default, Action<INamedTypeBuilder>? buildType = null)
Parameters
Type Name Description
IAdviser<INamespaceOrNamedType> adviser

An adviser for a named type or namespace.

string name

The interface name.

OverrideStrategy whenExists

Determines the implementation strategy when an interface of the same name is already declared in the target type or namespace. The default strategy is to fail with a compile-time error.

Action<INamedTypeBuilder> buildType

An optional delegate that modifies the INamedTypeBuilder that represents the introduced interface.

Returns
Type Description
IIntroductionAdviceResult<INamedType>

An IIntroductionAdviceResult<T> that exposes the outcome of the operation and the introduced INamedType.

See Also