System.Linq.Expressions.Expression.MakeUnary C# (CSharp) Method

MakeUnary() public static method

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).
return 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

Ejemplo n.º 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