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

MakeUnary() public static méthode

Creates a UnaryExpression, given an operand, by calling the appropriate factory method.
Thrown when does not correspond to a unary expression. Thrown when is null.
public static MakeUnary ( ExpressionType unaryType, Expression operand, Type type ) : UnaryExpression
unaryType ExpressionType The that specifies the type of unary operation.
operand Expression An that represents the operand.
type Type The that specifies the type to be converted to (pass null if not applicable).
Résultat UnaryExpression
        public static UnaryExpression MakeUnary(ExpressionType unaryType, Expression operand, Type type)
        {
            return MakeUnary(unaryType, operand, type, method: null);
        }

Same methods

Expression::MakeUnary ( ExpressionType unaryType, Expression operand, Type type, MethodInfo method ) : UnaryExpression

Usage Example

Exemple #1
0
        public void Typed(Linq.ExpressionType expression, Type type = null)
        {
            var operandType = typeof(object);

            type ??= operandType;

            var expected = LinqExpression.MakeUnary(expression, LinqExpression.Parameter(operandType), type);

            var actual = $@"
@prefix : <http://example.com/> .
@prefix xt: <http://example.com/ExpressionTypes/> .

:s
    :unaryExpressionType xt:{expression} ;
    :unaryOperand [
        :parameterType [
            :typeName ""{operandType}"" ;
        ] ;
    ] ;
    :unaryType [
        :typeName ""{type}"" ;
    ] ;
.
";

            ShouldBe(actual, expected);
        }
All Usage Examples Of System.Linq.Expressions.Expression::MakeUnary
Expression