System.Linq.Expressions.Expression.IfThenElse C# (CSharp) Méthode

IfThenElse() public static méthode

Creates a ConditionalExpression.
public static IfThenElse ( Expression test, Expression ifTrue, Expression ifFalse ) : ConditionalExpression
test Expression An to set the property equal to.
ifTrue Expression An to set the property equal to.
ifFalse Expression An to set the property equal to.
Résultat ConditionalExpression
        public static ConditionalExpression IfThenElse(Expression test, Expression ifTrue, Expression ifFalse)
        {
            return Condition(test, ifTrue, ifFalse, typeof(void));
        }
    }

Usage Example

Exemple #1
0
        public void IfThenElse()
        {
            var param    = LinqExpression.Parameter(typeof(bool));
            var expected = LinqExpression.IfThenElse(param, param, param);

            using var g = new GraphEngine.Graph();
            g.LoadFromString(@"
@prefix : <http://example.com/> .

:s
    a :IfThenElse ;
    :conditionTest _:param ;
    :conditionIfTrue _:param ;
    :conditionIfFalse _:param ;
.

_:param
    :parameterType [
        :typeName ""System.Boolean"" ;
    ] ;
.
");
            var s = g.GetUriNode(":s");

            var actual = Expression.Parse(s).LinqExpression;

            Console.WriteLine(actual.GetDebugView());

            actual.Should().Be(expected);
        }
All Usage Examples Of System.Linq.Expressions.Expression::IfThenElse
Expression