本文整理汇总了C#中IExpression类的典型用法代码示例。如果您正苦于以下问题:C# IExpression类的具体用法?C# IExpression怎么用?C# IExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IExpression类属于命名空间,在下文中一共展示了IExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GroupConcat
public GroupConcat(bool distinct,
IList<IExpression> exprList,
IExpression orderBy,
bool isDesc,
IList<IExpression> appendedColumnNames,
string separator)
: base("GROUP_CONCAT", exprList)
{
IsDistinct = distinct;
OrderBy = orderBy;
IsDesc = isDesc;
if (appendedColumnNames == null || appendedColumnNames.IsEmpty())
{
AppendedColumnNames = new List<IExpression>(0);
}
else if (appendedColumnNames is List<IExpression>)
{
AppendedColumnNames = appendedColumnNames;
}
else
{
AppendedColumnNames = new List<IExpression>(
appendedColumnNames);
}
Separator = separator ?? ",";
}
示例2: Selector
/// <summary> Ctor.</summary>
/// <param name="selector">Selector.
/// </param>
/// <param name="root">Root expression of the parsed selector.
/// </param>
/// <param name="identifiers">Identifiers used by the selector. The key
/// into the <tt>Map</tt> is name of the identifier and the value is an
/// instance of <tt>Identifier</tt>.
/// </param>
private Selector(System.String selector, IExpression root, System.Collections.IDictionary identifiers)
{
selector_ = selector;
root_ = root;
//UPGRADE_ISSUE: Method 'java.util.Collections.unmodifiableMap' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javautilCollectionsunmodifiableMap_javautilMap"'
identifiers_ = identifiers;
}
示例3: GetExpression
protected override IExpression GetExpression(CSharpElementFactory factory, IExpression contractExpression)
{
var expression = isDictionary
? factory.CreateExpression(
string.Format("$0.{0}(pair => pair.{1} != null)", nameof(Enumerable.All), nameof(KeyValuePair<int, int>.Value)),
contractExpression)
: factory.CreateExpression(string.Format("$0.{0}(item => item != null)", nameof(Enumerable.All)), contractExpression);
var invokedExpression = (IReferenceExpression)((IInvocationExpression)expression).InvokedExpression;
Debug.Assert(invokedExpression != null);
var allMethodReference = invokedExpression.Reference;
var enumerableType = new DeclaredTypeFromCLRName(ClrTypeNames.Enumerable, Provider.PsiModule).GetTypeElement();
Debug.Assert(enumerableType != null);
var allMethod = enumerableType.Methods.First(method => method.AssertNotNull().ShortName == nameof(Enumerable.All));
Debug.Assert(allMethod != null);
allMethodReference.BindTo(allMethod);
return expression;
}
示例4: RepeationByExpression
public RepeationByExpression(int count1, int count2, IExpression value, IExpression by)
{
this.count1 = count1;
this.count2 = count2;
this.value = value;
this.by = by;
}
示例5: PrintNode
private void PrintNode(IExpression node, int indent)
{
if (node == null)
return;
AppendLine(indent, "{" + node.GetType().Name + "}");
if (node is BinaryExpression)
PrintResolvedBinaryExpression((BinaryExpression)node, indent + 1);
else if (node is Cast)
PrintResolvedCast((Cast)node, indent + 1);
else if (node is Constant)
PrintResolvedConstant((Constant)node, indent + 1);
else if (node is FieldAccess)
PrintResolvedFieldAccess((FieldAccess)node, indent + 1);
else if (node is Index)
PrintResolvedIndex((Index)node, indent + 1);
else if (node is MethodCall)
PrintResolvedMethodCall((MethodCall)node, indent + 1);
else if (node is UnaryExpression)
PrintResolvedUnaryExpression((UnaryExpression)node, indent + 1);
else if (node is VariableAccess)
PrintResolvedVariableAccess((VariableAccess)node, indent + 1);
else if (node is TypeAccess)
PrintResolvedTypeAccess((TypeAccess)node, indent + 1);
else
throw new NotSupportedException();
}
示例6: True
public IIfStatementOptions True(IExpression condition)
{
var ifStatement = new ConditionalStatement();
ifStatement.Condition = condition;
return new IfStatementOptions(ifStatement);
}
示例7: CompareExpression
public CompareExpression(ComparisonOperator operation, IExpression left, IExpression right)
: base(left, right)
{
this.operation = operation;
switch (operation)
{
case ComparisonOperator.NonStrictEqual:
this.function = NonStrictEqual;
break;
case ComparisonOperator.NonStrictNotEqual:
this.function = NonStrictNotEqual;
break;
case ComparisonOperator.Equal:
this.function = Operators.CompareObjectEqual;
break;
case ComparisonOperator.NotEqual:
this.function = Operators.CompareObjectNotEqual;
break;
case ComparisonOperator.Less:
this.function = Operators.CompareObjectLess;
break;
case ComparisonOperator.LessEqual:
this.function = Operators.CompareObjectLessEqual;
break;
case ComparisonOperator.Greater:
this.function = Operators.CompareObjectGreater;
break;
case ComparisonOperator.GreaterEqual:
this.function = Operators.CompareObjectGreaterEqual;
break;
default:
throw new ArgumentException("Invalid operator");
}
}
示例8: CreateQueryPlan
/// <summary>
/// Creates a query plan using a logic expression
/// </summary>
/// <param name="myExpression">The logic expression</param>
/// <param name="myIsLongRunning">Determines whether it is anticipated that the request could take longer</param>
/// <param name="myTransaction">The current transaction token</param>
/// <param name="mySecurity">The current security token</param>
/// <returns>A query plan</returns>
public IQueryPlan CreateQueryPlan(IExpression myExpression,
Boolean myIsLongRunning,
Int64 myTransaction,
SecurityToken mySecurity)
{
IQueryPlan result;
switch (myExpression.TypeOfExpression)
{
case TypeOfExpression.Binary:
result = GenerateFromBinaryExpression((BinaryExpression) myExpression, myIsLongRunning, myTransaction, mySecurity);
break;
case TypeOfExpression.Unary:
result = GenerateFromUnaryExpression((UnaryExpression)myExpression, myTransaction, mySecurity);
break;
case TypeOfExpression.Property:
result = GenerateFromPropertyExpression((PropertyExpression)myExpression, myTransaction, mySecurity);
break;
default:
throw new ArgumentOutOfRangeException();
}
return result;
}
示例9: ExpressionTest
public void ExpressionTest(int row, int column)
{
var expressions = new IExpression[]
{
new ConstantExpression(0),
new CellRefereceExpression(new CellAddress(1, 1)),
new BinaryExpression(new ConstantExpression(1), OperatorManager.Default.Operators['*'],
new ConstantExpression(2)),
new UnaryExpression(OperatorManager.Default.Operators['-'], new ConstantExpression(9)),
new ConstantExpression(91),
new ConstantExpression("text"),
};
var cells = expressions.Select((e, i) => new Cell(new CellAddress(i / column, i % column), e)).ToArray();
var spreadsheet = ReadSpreadsheet($"{row} {column}", expressions);
Assert.AreEqual(row, spreadsheet.RowCount, "Wrong row count");
Assert.AreEqual(column, spreadsheet.ColumnCount, "Wrong column count");
var array = spreadsheet.ToArray();
Assert.AreEqual(row * column, array.Length, "Wrong container size");
CollectionAssert.AreEqual(cells.Take(array.Length),
array,
new GenericComparer<Cell>((x,y) => string.Compare(x.ToString(), y.ToString(), StringComparison.Ordinal)));
}
示例10: Evaluate
protected override object Evaluate(IExpression left, IExpression right, ExecutionState state)
{
object b = TokenParser.VerifyUnderlyingType(right.Evaluate(state, token));
object a = TokenParser.VerifyUnderlyingType(left.Evaluate(state, token));
decimal x, y;
//typeof(decimal).IsAssignableFrom(typeof(a))
if (a is decimal)
x = (decimal)a;
else
{
//if(a is int || a is long || a is double || a is float || a is short
TypeConverter tc = TypeDescriptor.GetConverter(a);
if (!tc.CanConvertTo(typeof(decimal)))
return string.Concat(a, b);
x = (decimal)tc.ConvertTo(a, typeof(decimal));
}
if (b is decimal)
y = (decimal)b;
else
{
TypeConverter tc = TypeDescriptor.GetConverter(b);
if (!tc.CanConvertTo(typeof(decimal)))
return string.Concat(a, b);
y = (decimal)tc.ConvertTo(b, typeof(decimal));
}
return x + y;
}
示例11: AdditionNonterminalExpression
public AdditionNonterminalExpression(
IExpression expr1,
IExpression expr2)
{
_expr1 = expr1;
_expr2 = expr2;
}
示例12: WriteToDisk
private void WriteToDisk(IExpression expression, Resolver resolver)
{
var name = "Output.exe";
var assemblyName = new AssemblyName(name);
var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
assemblyName,
AssemblyBuilderAccess.RunAndSave
);
var moduleBuilder = assemblyBuilder.DefineDynamicModule(name);
var programClass = moduleBuilder.DefineType("Program", TypeAttributes.Public);
var mainMethod = programClass.DefineMethod("Main", MethodAttributes.Public | MethodAttributes.Static, null, new[] { typeof(string[]) });
var il = mainMethod.GetILGenerator();
new Compiler(il, resolver).Compile(expression);
programClass.CreateType();
assemblyBuilder.SetEntryPoint(programClass.GetMethod("Main"));
assemblyBuilder.Save(name);
}
示例13: CompareExpression
public CompareExpression(ComparisonOperator operation, IExpression left, IExpression right)
: base(left, right)
{
this.operation = operation;
switch (operation)
{
case ComparisonOperator.Equal:
this.function = Operators.CompareObjectEqual;
break;
case ComparisonOperator.NotEqual:
this.function = Operators.CompareObjectNotEqual;
break;
case ComparisonOperator.Less:
this.function = Operators.CompareObjectLess;
break;
case ComparisonOperator.LessEqual:
this.function = Operators.CompareObjectLessEqual;
break;
case ComparisonOperator.Greater:
this.function = Operators.CompareObjectGreater;
break;
case ComparisonOperator.GreaterEqual:
this.function = Operators.CompareObjectGreaterEqual;
break;
}
}
示例14: InstanceCreationExpression
public InstanceCreationExpression(string type, int row, int col, IExpression arraySize = null)
: base(row, col)
{
CreatedTypeName = type;
ArraySize = arraySize;
IsArrayCreation = arraySize != null;
}
示例15: Compile
public void Compile(IExpression expression)
{
Require.NotNull(expression, "expression");
expression.Accept(new Visitor(this));
if (
(expression.Type.IsValueType || _resolver.Options.ResultType.IsValueType) &&
expression.Type != _resolver.Options.ResultType
) {
try
{
ExtendedConvertToType(expression.Type, _resolver.Options.ResultType, true);
}
catch (Exception ex)
{
throw new ExpressionsException("Cannot convert expression result to expected result type", ExpressionsExceptionType.InvalidExplicitCast, ex);
}
_il.Emit(OpCodes.Box, _resolver.Options.ResultType);
}
else if (expression.Type.IsValueType)
{
_il.Emit(OpCodes.Box, expression.Type);
}
else if (!_resolver.Options.ResultType.IsAssignableFrom(expression.Type))
{
throw new ExpressionsException("Cannot convert expression result to expected result type", ExpressionsExceptionType.TypeMismatch);
}
_il.Emit(OpCodes.Ret);
}