/// <summary>
/// Creates a <see cref="ConditionalExpression"/>.
/// </summary>
/// <param name="test">An <see cref="Expression"/> to set the <see cref="P:ConditionalExpression.Test"/> property equal to.</param>
/// <param name="ifTrue">An <see cref="Expression"/> to set the <see cref="P:ConditionalExpression.IfTrue"/> property equal to.</param>
/// <param name="ifFalse">An <see cref="Expression"/> to set the <see cref="P:ConditionalExpression.IfFalse"/> property equal to.</param>
/// <returns>A <see cref="ConditionalExpression"/> that has the <see cref="P:Expression.NodeType"/> property equal to
/// <see cref="F:ExpressionType.Conditional"/> and the <see cref="P:ConditionalExpression.Test"/>, <see cref="P:ConditionalExpression.IfTrue"/>,
/// and <see cref="P:ConditionalExpression.IfFalse"/> properties set to the specified values.</returns>
public static ConditionalExpression Condition(Expression test, Expression ifTrue, Expression ifFalse)
{
RequiresCanRead(test, "test");
RequiresCanRead(ifTrue, "ifTrue");
RequiresCanRead(ifFalse, "ifFalse");
if (test.Type != typeof(bool))
{
throw Error.ArgumentMustBeBoolean();
}
if (!TypeUtils.AreEquivalent(ifTrue.Type, ifFalse.Type))
{
throw Error.ArgumentTypesMustMatch();
}
return(ConditionalExpression.Make(test, ifTrue, ifFalse, ifTrue.Type));
}