EnumConditionExpression

What it is

EnumConditionExpression is used to evaluate a Enum property (of field or variable). Depending on the outcome, the result will then be either Enum1 or Enum2.

Code example

public EnumProperty EnumExample1 => EnumProperty(description: "first example");
public EnumProperty EnumExample2 => EnumProperty(description: "second example");

public ReadOnlyEnumProperty EnumResult
{
    get
    {
        return CalculatedEnumProperty(() => 
            EnumExample1.IsEqualTo(EnumExample2).IsTrueElse(EnumExample1, EnumExample2));
    }  
}

 

Explanation of the example

Line 9 evaluates if EnumExample1 is equal to EnumExample2.
If so, EnumExample1 will be assigned to the CalculatedEnumProperty EnumResult, otherwise EnumExample2 will be assigned to EnumResult.