Open sandboxFocus

Method IntroduceEnum

IntroduceEnum(INamespaceOrNamedType, string, Action<IEnumBuilder>, OverrideStrategy)

Introduces a new enum to the target namespace or type.

Declaration
IIntroductionAdviceResult<INamedType> IntroduceEnum(INamespaceOrNamedType targetNamespaceOrType, string name, Action<IEnumBuilder> buildEnum, OverrideStrategy whenExists = OverrideStrategy.Default)
Parameters
Type Name Description
INamespaceOrNamedType targetNamespaceOrType

The namespace or type into which the enum must be introduced.

string name

The name of the introduced enum.

Action<IEnumBuilder> buildEnum

A callback that configures the introduced enum. It must add at least one member, because an enum that declares no member has no possible value. The parameter is required and precedes whenExists for that reason: the callback is the only way to add a member, so a call that omitted it could only produce an empty enum.

OverrideStrategy whenExists

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

Returns
Type Description
IIntroductionAdviceResult<INamedType>

An IIntroductionAdviceResult<T> representing the result of the advice. The Declaration property provides access to the introduced enum. Unlike the result of introducing a class, this result must not be used to introduce members, because an enum accepts none.