private ExpressionType GetUnaryOperator(NRefactory.UnaryOperatorType @operator) { ExpressionType type; if (!Enum.TryParse<ExpressionType>(@operator.ToString(), true, out type)) { switch (@operator) { case ICSharpCode.NRefactory.CSharp.UnaryOperatorType.BitNot: return ExpressionType.Not; case ICSharpCode.NRefactory.CSharp.UnaryOperatorType.Decrement: return ExpressionType.Decrement; case ICSharpCode.NRefactory.CSharp.UnaryOperatorType.Increment: return ExpressionType.Increment; case ICSharpCode.NRefactory.CSharp.UnaryOperatorType.Minus: return ExpressionType.Negate; case ICSharpCode.NRefactory.CSharp.UnaryOperatorType.Not: return ExpressionType.NotEqual; case ICSharpCode.NRefactory.CSharp.UnaryOperatorType.Plus: return ExpressionType.Add; case ICSharpCode.NRefactory.CSharp.UnaryOperatorType.PostDecrement: return ExpressionType.PostDecrementAssign; case ICSharpCode.NRefactory.CSharp.UnaryOperatorType.PostIncrement: return ExpressionType.PostIncrementAssign; default: throw new NotSupportedException(); } } return type; }
private ExpressionType GetBinaryOperator(NRefactory.BinaryOperatorType @operator) { ExpressionType type; if (!Enum.TryParse<ExpressionType>(@operator.ToString(), true, out type)) { switch (@operator) { case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.Any: return ExpressionType.Add; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.BitwiseAnd: return ExpressionType.And; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.BitwiseOr: return ExpressionType.Or; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.ConditionalAnd: return ExpressionType.AndAlso; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.ConditionalOr: return ExpressionType.OrElse; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.Divide: return ExpressionType.Divide; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.Equality: return ExpressionType.Equal; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.InEquality: return ExpressionType.NotEqual; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.Modulus: return ExpressionType.Modulo; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.Multiply: return ExpressionType.Multiply; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.NullCoalescing: return ExpressionType.Coalesce; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.ShiftLeft: return ExpressionType.LeftShift; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.ShiftRight: return ExpressionType.RightShift; } } return type; }