本文整理汇总了C#中CodeBinaryOperatorType类的典型用法代码示例。如果您正苦于以下问题:C# CodeBinaryOperatorType类的具体用法?C# CodeBinaryOperatorType怎么用?C# CodeBinaryOperatorType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CodeBinaryOperatorType类属于命名空间,在下文中一共展示了CodeBinaryOperatorType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoBoolean
private void DoBoolean(BooleanExpression expression, CodeBinaryOperatorType operation)
{
var leftArgs = VisitChild(expression.Left, new CodeDomArg() { Scope = _codeStack.Peek().Scope });
var rightArgs = VisitChild(expression.Right, new CodeDomArg() { Scope = _codeStack.Peek().Scope });
Type leftType = Type.GetType(leftArgs.Scope.CodeDomReference.BaseType);
Type rightType = Type.GetType(rightArgs.Scope.CodeDomReference.BaseType);
if (leftType != rightType)
{
if (leftType == typeof(string))
{
var primitive = TablePrimitive.FromType(rightType);
leftArgs.CodeExpression = primitive.ToNative(leftArgs.CodeExpression);
}
else if(rightType == typeof(string))
{
var primitive = TablePrimitive.FromType(leftType);
rightArgs.CodeExpression = primitive.ToNative(rightArgs.CodeExpression);
}
}
if (leftArgs.Tag != null)
_codeStack.Peek().Tag = leftArgs.Tag;
if (rightArgs.Tag != null)
_codeStack.Peek().Tag = rightArgs.Tag;
_codeStack.Peek().CodeExpression = new CodeBinaryOperatorExpression(leftArgs.CodeExpression, operation, rightArgs.CodeExpression);
}
示例2: CodeBinaryOperatorExpression
public CodeBinaryOperatorExpression (CodeExpression left,
CodeBinaryOperatorType op,
CodeExpression right)
{
this.left = left;
this.op = op;
this.right = right;
}
示例3: Operator
string Operator(CodeBinaryOperatorType op)
{
switch (op)
{
case CodeBinaryOperatorType.Assign: return new string(new[] { Parser.AssignPre, Parser.Equal });
case CodeBinaryOperatorType.BooleanAnd: return Parser.AndTxt;
case CodeBinaryOperatorType.BooleanOr: return Parser.OrTxt;
default: throw new ArgumentOutOfRangeException("op");
}
}
示例4: OutputOperator
protected override void OutputOperator(CodeBinaryOperatorType op)
{
switch (op)
{
case CodeBinaryOperatorType.BitwiseAnd:
case CodeBinaryOperatorType.BooleanAnd: Output.Write("and"); break;
case CodeBinaryOperatorType.BitwiseOr:
case CodeBinaryOperatorType.BooleanOr: Output.Write("or"); break;
default: base.OutputOperator(op); break;
}
}
示例5: DoBooleanAggregate
private void DoBooleanAggregate(BooleanExpression expression, CodeBinaryOperatorType operation)
{
var leftArgs = VisitChild(expression.Left, new CodeDomArg() { Scope = _codeStack.Peek().Scope });
var rightArgs = VisitChild(expression.Right, new CodeDomArg() { Scope = _codeStack.Peek().Scope });
if (leftArgs.Tag != null)
_codeStack.Peek().Tag = leftArgs.Tag;
if (rightArgs.Tag != null)
_codeStack.Peek().Tag = rightArgs.Tag;
_codeStack.Peek().CodeExpression = new CodeBinaryOperatorExpression(leftArgs.CodeExpression, operation, rightArgs.CodeExpression);
}
示例6: BinaryOpOperatorExpression
public BinaryOpOperatorExpression(
Expression left,
Expression right,
CodeBinaryOperatorType op
)
{
if (left==null)
throw new ArgumentNullException("left");
if (right==null)
throw new ArgumentNullException("right");
this.left = left;
this.right = right;
this.op = op;
}
示例7: RuleEvaluationIncompatibleTypesException
protected RuleEvaluationIncompatibleTypesException(SerializationInfo serializeInfo, StreamingContext context) : base(serializeInfo, context)
{
if (serializeInfo == null)
{
throw new ArgumentNullException("serializeInfo");
}
string typeName = serializeInfo.GetString("left");
if (typeName != "null")
{
this.m_leftType = Type.GetType(typeName);
}
this.m_op = (CodeBinaryOperatorType) serializeInfo.GetValue("op", typeof(CodeBinaryOperatorType));
typeName = serializeInfo.GetString("right");
if (typeName != "null")
{
this.m_rightType = Type.GetType(typeName);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:18,代码来源:RuleEvaluationIncompatibleTypesException.cs
示例8: GetOperatorString
private string GetOperatorString(CodeBinaryOperatorType operatorType)
{
switch (operatorType)
{
case CodeBinaryOperatorType.Add:
return "+";
case CodeBinaryOperatorType.Subtract:
return "-";
case CodeBinaryOperatorType.Multiply:
return "*";
case CodeBinaryOperatorType.Divide:
return "/";
case CodeBinaryOperatorType.Modulus:
return "%";
case CodeBinaryOperatorType.Assign:
return "=";
case CodeBinaryOperatorType.IdentityInequality:
return "!=";
case CodeBinaryOperatorType.IdentityEquality:
return "===";
case CodeBinaryOperatorType.ValueEquality:
return "==";
case CodeBinaryOperatorType.BitwiseOr:
return "|";
case CodeBinaryOperatorType.BitwiseAnd:
return "&";
case CodeBinaryOperatorType.BooleanOr:
return "||";
case CodeBinaryOperatorType.BooleanAnd:
return "&&";
case CodeBinaryOperatorType.LessThan:
return "<";
case CodeBinaryOperatorType.LessThanOrEqual:
return "<=";
case CodeBinaryOperatorType.GreaterThan:
return ">";
case CodeBinaryOperatorType.GreaterThanOrEqual:
return ">=";
default:
throw new ArgumentOutOfRangeException();
}
}
示例9: CodeBinaryOperatorExpression
public CodeBinaryOperatorExpression(CodeExpression left, CodeBinaryOperatorType op, CodeExpression right)
{
}
示例10: OutputOperator
protected virtual void OutputOperator(CodeBinaryOperatorType op)
{
switch (op)
{
case CodeBinaryOperatorType.Add:
Output.Write('+');
break;
case CodeBinaryOperatorType.Subtract:
Output.Write('-');
break;
case CodeBinaryOperatorType.Multiply:
Output.Write('*');
break;
case CodeBinaryOperatorType.Divide:
Output.Write('/');
break;
case CodeBinaryOperatorType.Modulus:
Output.Write('%');
break;
case CodeBinaryOperatorType.Assign:
Output.Write('=');
break;
case CodeBinaryOperatorType.IdentityInequality:
Output.Write("!=");
break;
case CodeBinaryOperatorType.IdentityEquality:
Output.Write("==");
break;
case CodeBinaryOperatorType.ValueEquality:
Output.Write("==");
break;
case CodeBinaryOperatorType.BitwiseOr:
Output.Write('|');
break;
case CodeBinaryOperatorType.BitwiseAnd:
Output.Write('&');
break;
case CodeBinaryOperatorType.BooleanOr:
Output.Write("||");
break;
case CodeBinaryOperatorType.BooleanAnd:
Output.Write("&&");
break;
case CodeBinaryOperatorType.LessThan:
Output.Write('<');
break;
case CodeBinaryOperatorType.LessThanOrEqual:
Output.Write("<=");
break;
case CodeBinaryOperatorType.GreaterThan:
Output.Write('>');
break;
case CodeBinaryOperatorType.GreaterThanOrEqual:
Output.Write(">=");
break;
}
}
示例11: MapOperatorToMethod
[SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] // bogus since the casts are in different case statements
internal static MethodInfo MapOperatorToMethod(
CodeBinaryOperatorType op,
Type lhs,
CodeExpression lhsExpression,
Type rhs,
CodeExpression rhsExpression,
RuleValidation validator,
out ValidationError error)
{
// determine what the method name should be
string methodName;
string message;
OperatorGrouping group;
switch (op)
{
case CodeBinaryOperatorType.ValueEquality:
methodName = "op_Equality";
group = OperatorGrouping.Equality;
break;
case CodeBinaryOperatorType.GreaterThan:
methodName = "op_GreaterThan";
group = OperatorGrouping.Relational;
break;
case CodeBinaryOperatorType.GreaterThanOrEqual:
methodName = "op_GreaterThanOrEqual";
group = OperatorGrouping.Relational;
break;
case CodeBinaryOperatorType.LessThan:
methodName = "op_LessThan";
group = OperatorGrouping.Relational;
break;
case CodeBinaryOperatorType.LessThanOrEqual:
methodName = "op_LessThanOrEqual";
group = OperatorGrouping.Relational;
break;
case CodeBinaryOperatorType.Add:
methodName = "op_Addition";
group = OperatorGrouping.Arithmetic;
break;
case CodeBinaryOperatorType.Subtract:
methodName = "op_Subtraction";
group = OperatorGrouping.Arithmetic;
break;
case CodeBinaryOperatorType.Multiply:
methodName = "op_Multiply";
group = OperatorGrouping.Arithmetic;
break;
case CodeBinaryOperatorType.Divide:
methodName = "op_Division";
group = OperatorGrouping.Arithmetic;
break;
case CodeBinaryOperatorType.Modulus:
methodName = "op_Modulus";
group = OperatorGrouping.Arithmetic;
break;
case CodeBinaryOperatorType.BitwiseAnd:
methodName = "op_BitwiseAnd";
group = OperatorGrouping.Arithmetic;
break;
case CodeBinaryOperatorType.BitwiseOr:
methodName = "op_BitwiseOr";
group = OperatorGrouping.Arithmetic;
break;
default:
Debug.Assert(false, "Operator " + op.ToString() + " not implemented");
message = string.Format(CultureInfo.CurrentCulture, Messages.BinaryOpNotSupported, op.ToString());
error = new ValidationError(message, ErrorNumbers.Error_CodeExpressionNotHandled);
return null;
}
// NOTE: types maybe NullLiteral, which signifies the constant "null"
List<MethodInfo> candidates = new List<MethodInfo>();
bool lhsNullable = ConditionHelper.IsNullableValueType(lhs);
bool rhsNullable = ConditionHelper.IsNullableValueType(rhs);
Type lhsType0 = (lhsNullable) ? Nullable.GetUnderlyingType(lhs) : lhs;
Type rhsType0 = (rhsNullable) ? Nullable.GetUnderlyingType(rhs) : rhs;
// special cases for enums
if (lhsType0.IsEnum)
{
// only 3 cases (U = underlying type of E):
// E = E + U
// U = E - E
// E = E - U
// plus the standard comparisons (E == E, E > E, etc.)
// need to also allow E == 0
Type underlyingType;
switch (op)
{
case CodeBinaryOperatorType.Add:
underlyingType = EnumHelper.GetUnderlyingType(lhsType0);
if ((underlyingType != null) &&
(RuleValidation.TypesAreAssignable(rhsType0, underlyingType, rhsExpression, out error)))
{
error = null;
return new EnumOperationMethodInfo(lhs, op, rhs, false);
}
break;
//.........这里部分代码省略.........
示例12: OutputOperator
protected override void OutputOperator(CodeBinaryOperatorType op)
{
if (op == CodeBinaryOperatorType.StringConcat)
base.Output.Write("~");
else
base.OutputOperator(op);
}
示例13: EnumOpImpl
private static ET EnumOpImpl(CodeBinaryOperatorType opType, ET l, ET[] rights, int index)
{
ET r;
if (index == rights.Length - 1) r = rights[index];
else r = EnumOpImpl(opType, rights[index], rights, index + 1);
return new BuilderBinaryOperator(l, opType, r);
}
示例14: BinaryOperator
/// <summary>
/// フィールドへの参照を作成します。
/// </summary>
/// <param name="target"></param>
/// <param name="name"></param>
/// <returns></returns>
private static ET BinaryOperator(ET l, CodeBinaryOperatorType op, ET r)
{
return new BuilderBinaryOperator(l, op, r);
}
示例15: OutputOperator
protected override void OutputOperator(CodeBinaryOperatorType op)
{
switch (op)
{
case CodeBinaryOperatorType.Modulus:
base.Output.Write("Mod");
return;
case CodeBinaryOperatorType.IdentityInequality:
base.Output.Write("<>");
return;
case CodeBinaryOperatorType.IdentityEquality:
base.Output.Write("Is");
return;
case CodeBinaryOperatorType.ValueEquality:
base.Output.Write("=");
return;
case CodeBinaryOperatorType.BitwiseOr:
base.Output.Write("Or");
return;
case CodeBinaryOperatorType.BitwiseAnd:
base.Output.Write("And");
return;
case CodeBinaryOperatorType.BooleanOr:
base.Output.Write("OrElse");
return;
case CodeBinaryOperatorType.BooleanAnd:
base.Output.Write("AndAlso");
return;
}
base.OutputOperator(op);
}