本文整理汇总了C#中Microsoft.CSharp.Expressions.DynamicCSharpArgument类的典型用法代码示例。如果您正苦于以下问题:C# DynamicCSharpArgument类的具体用法?C# DynamicCSharpArgument怎么用?C# DynamicCSharpArgument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DynamicCSharpArgument类属于Microsoft.CSharp.Expressions命名空间,在下文中一共展示了DynamicCSharpArgument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssignBinaryDynamicCSharpExpression
internal AssignBinaryDynamicCSharpExpression(Type context, CSharpBinderFlags binderFlags, CSharpExpressionType binaryType, DynamicCSharpArgument left, DynamicCSharpArgument right)
: base(context, binderFlags)
{
OperationNodeType = binaryType;
Left = left;
Right = right;
}
示例2: ReduceDynamicAssignment
public static Expression ReduceDynamicAssignment(DynamicCSharpArgument left, Func<Expression, Expression> functionalOp, CSharpBinderFlags flags, bool prefix = true)
{
var lhs = MakeWriteable(left.Expression);
var dynamicMember = lhs as GetMemberDynamicCSharpExpression;
if (dynamicMember != null)
{
return ReduceDynamicMember(dynamicMember, functionalOp, flags, prefix);
}
var dynamicIndex = lhs as GetIndexDynamicCSharpExpression;
if (dynamicIndex != null)
{
return ReduceDynamicIndex(dynamicIndex, functionalOp, flags, prefix);
}
return Helpers.ReduceAssignment(lhs, functionalOp, prefix);
}
示例3: VisitDynamicArgument
protected internal virtual DynamicCSharpArgument VisitDynamicArgument(DynamicCSharpArgument node)
{
return node.Update(Visit(node.Expression));
}
示例4: Update
/// <summary>
/// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
/// </summary>
/// <param name="operand">The <see cref="Operand" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public UnaryDynamicCSharpExpression Update(DynamicCSharpArgument operand)
{
if (operand == this.Operand)
{
return this;
}
return DynamicCSharpExpression.MakeDynamicUnary(OperationNodeType, operand, Flags, Context);
}
示例5: MakeDynamicUnary
/// <summary>
/// Creates a new expression representing a dynamically bound unary operation with the specified binder flags and the specified type context.
/// </summary>
/// <param name="unaryType">The type of the unary operation to perform.</param>
/// <param name="operand">The dynamic argument representing the operand of the operation.</param>
/// <param name="binderFlags">The binder flags to use for the dynamic operation.</param>
/// <param name="context">The type representing the context in which the dynamic operation is bound.</param>
/// <returns>A new expression representing a dynamically bound unary operation.</returns>
public static UnaryDynamicCSharpExpression MakeDynamicUnary(ExpressionType unaryType, DynamicCSharpArgument operand, CSharpBinderFlags binderFlags, Type context)
{
ContractUtils.RequiresNotNull(operand, nameof(operand));
CheckUnary(unaryType);
switch (unaryType)
{
case ExpressionType.NegateChecked:
binderFlags |= CSharpBinderFlags.CheckedContext;
break;
}
return new UnaryDynamicCSharpExpression(context, binderFlags, unaryType, operand);
}
示例6: ReduceCore
private Expression ReduceCore(DynamicCSharpArgument left)
{
var functionalOp = new Func<Expression, Expression>(lhs =>
{
var operation = default(ExpressionType);
switch (OperationNodeType)
{
case CSharpExpressionType.AddAssign:
case CSharpExpressionType.AddAssignChecked:
operation = ExpressionType.AddAssign;
break;
case CSharpExpressionType.SubtractAssign:
case CSharpExpressionType.SubtractAssignChecked:
operation = ExpressionType.SubtractAssign;
break;
case CSharpExpressionType.MultiplyAssign:
case CSharpExpressionType.MultiplyAssignChecked:
operation = ExpressionType.MultiplyAssign;
break;
case CSharpExpressionType.DivideAssign:
operation = ExpressionType.DivideAssign;
break;
case CSharpExpressionType.ModuloAssign:
operation = ExpressionType.ModuloAssign;
break;
case CSharpExpressionType.AndAssign:
operation = ExpressionType.AndAssign;
break;
case CSharpExpressionType.OrAssign:
operation = ExpressionType.OrAssign;
break;
case CSharpExpressionType.ExclusiveOrAssign:
operation = ExpressionType.ExclusiveOrAssign;
break;
case CSharpExpressionType.LeftShiftAssign:
operation = ExpressionType.LeftShiftAssign;
break;
case CSharpExpressionType.RightShiftAssign:
operation = ExpressionType.RightShiftAssign;
break;
default:
throw ContractUtils.Unreachable;
}
var args = new[]
{
CSharpArgumentInfo.Create(GetArgumentInfoFlags(Left), null),
CSharpArgumentInfo.Create(GetArgumentInfoFlags(Right), null),
};
var binder = Binder.BinaryOperation(Flags, operation, Context, args);
var dynamic = DynamicHelpers.MakeDynamic(typeof(object), binder, new[] { lhs, Right.Expression }, new[] { lhs.Type, Right.Expression.Type });
var leftType = Left.Expression.Type;
if (leftType != dynamic.Type)
{
var convert = Binder.Convert(CSharpBinderFlags.ConvertExplicit, leftType, Context);
dynamic = DynamicHelpers.MakeDynamic(leftType, convert, new[] { dynamic }, null);
}
return dynamic;
});
var flags = Flags | CSharpBinderFlags.ValueFromCompoundAssignment;
var res = DynamicHelpers.ReduceDynamicAssignment(left, functionalOp, flags);
return res;
}
示例7: MakeDynamicBinaryAssign
/// <summary>
/// Creates a new expression representing a dynamically bound binary assignment operation with the specified binder flags.
/// </summary>
/// <param name="binaryType">The type of the binary operation to perform.</param>
/// <param name="left">The dynamic argument representing the left operand of the operation.</param>
/// <param name="right">The dynamic argument representing the right operand of the operation.</param>
/// <param name="binderFlags">The binder flags to use for the dynamic operation.</param>
/// <returns>A new expression representing a dynamically bound binary operation.</returns>
public static AssignBinaryDynamicCSharpExpression MakeDynamicBinaryAssign(CSharpExpressionType binaryType, DynamicCSharpArgument left, DynamicCSharpArgument right, CSharpBinderFlags binderFlags)
{
return MakeDynamicBinaryAssign(binaryType, left, right, binderFlags, null);
}
示例8: DynamicPreIncrementAssignChecked
public static AssignUnaryDynamicCSharpExpression DynamicPreIncrementAssignChecked(DynamicCSharpArgument operand, CSharpBinderFlags binderFlags, Type context)
{
return MakeDynamicUnaryAssign(CSharpExpressionType.PreIncrementAssignChecked, operand, binderFlags, context);
}
示例9: DynamicPostIncrementAssignChecked
/// <summary>
/// Creates a new expression representing a dynamically bound unary 'PostIncrementAssignChecked' operation.
/// </summary>
/// <param name="operand">The dynamic argument representing the operand of the operation.</param>
/// <returns>A new expression representing a dynamically bound unary 'PostIncrementAssignChecked' operation.</returns>
public static AssignUnaryDynamicCSharpExpression DynamicPostIncrementAssignChecked(DynamicCSharpArgument operand)
{
return MakeDynamicUnaryAssign(CSharpExpressionType.PostIncrementAssignChecked, operand);
}
示例10: DynamicPreDecrementAssign
/// <summary>
/// Creates a new expression representing a dynamically bound unary 'PreDecrementAssign' operation.
/// </summary>
/// <param name="operand">The dynamic argument representing the operand of the operation.</param>
/// <returns>A new expression representing a dynamically bound unary 'PreDecrementAssign' operation.</returns>
public static AssignUnaryDynamicCSharpExpression DynamicPreDecrementAssign(DynamicCSharpArgument operand)
{
return MakeDynamicUnaryAssign(CSharpExpressionType.PreDecrementAssign, operand);
}
示例11: DynamicAndAssign
/// <summary>
/// Creates a new expression representing a dynamically bound binary 'AndAssign' operation.
/// </summary>
/// <param name="left">The dynamic argument representing the left operand of the operation.</param>
/// <param name="right">The dynamic argument representing the right operand of the operation.</param>
/// <returns>A new expression representing a dynamically bound binary 'AndAssign' operation.</returns>
public static AssignBinaryDynamicCSharpExpression DynamicAndAssign(DynamicCSharpArgument left, DynamicCSharpArgument right)
{
return MakeDynamicBinaryAssign(CSharpExpressionType.AndAssign, left, right);
}
示例12: DynamicSubtractAssignChecked
public static AssignBinaryDynamicCSharpExpression DynamicSubtractAssignChecked(DynamicCSharpArgument left, DynamicCSharpArgument right, CSharpBinderFlags binderFlags)
{
return MakeDynamicBinaryAssign(CSharpExpressionType.SubtractAssignChecked, left, right, binderFlags);
}
示例13: DynamicMultiplyAssignChecked
/// <summary>
/// Creates a new expression representing a dynamically bound binary 'MultiplyAssignChecked' operation.
/// </summary>
/// <param name="left">The dynamic argument representing the left operand of the operation.</param>
/// <param name="right">The dynamic argument representing the right operand of the operation.</param>
/// <returns>A new expression representing a dynamically bound binary 'MultiplyAssignChecked' operation.</returns>
public static AssignBinaryDynamicCSharpExpression DynamicMultiplyAssignChecked(DynamicCSharpArgument left, DynamicCSharpArgument right)
{
return MakeDynamicBinaryAssign(CSharpExpressionType.MultiplyAssignChecked, left, right);
}
示例14: DynamicRightShiftAssign
public static AssignBinaryDynamicCSharpExpression DynamicRightShiftAssign(DynamicCSharpArgument left, DynamicCSharpArgument right, CSharpBinderFlags binderFlags)
{
return MakeDynamicBinaryAssign(CSharpExpressionType.RightShiftAssign, left, right, binderFlags);
}
示例15: DynamicAssign
/// <summary>
/// Creates a new expression representing a dynamically bound binary assignment operation with the specified binder flags and the specified type context.
/// </summary>
/// <param name="left">The dynamic argument representing the left operand of the operation.</param>
/// <param name="right">The dynamic argument representing the right operand of the operation.</param>
/// <param name="binderFlags">The binder flags to use for the dynamic operation.</param>
/// <param name="context">The type representing the context in which the dynamic operation is bound.</param>
/// <returns>A new expression representing a dynamically bound binary operation.</returns>
public static AssignBinaryDynamicCSharpExpression DynamicAssign(DynamicCSharpArgument left, DynamicCSharpArgument right, CSharpBinderFlags binderFlags, Type context)
{
return MakeDynamicBinaryAssign(CSharpExpressionType.Assign, left, right, binderFlags, context);
}