• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IExpression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IExpression的典型用法代码示例。如果您正苦于以下问题:C# IExpression类的具体用法?C# IExpression怎么用?C# IExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IExpression类属于命名空间,在下文中一共展示了IExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 ?? ",";
        }
开发者ID:tupunco,项目名称:Tup.Cobar4Net,代码行数:27,代码来源:GroupConcat.cs


示例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;
 }
开发者ID:jamsel,项目名称:jamsel,代码行数:16,代码来源:Selector.cs


示例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;
        }
开发者ID:prodot,项目名称:ReCommended-Extension,代码行数:26,代码来源:CollectionAllItemsNotNull.cs


示例4: RepeationByExpression

 public RepeationByExpression(int count1, int count2, IExpression value, IExpression by)
 {
     this.count1 = count1;
     this.count2 = count2;
     this.value = value;
     this.by = by;
 }
开发者ID:vf1,项目名称:bnf2dfa,代码行数:7,代码来源:RepeationByExpression.cs


示例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();
        }
开发者ID:parsnips,项目名称:Expressions,代码行数:28,代码来源:ExpressionPrinter.cs


示例6: True

        public IIfStatementOptions True(IExpression condition)
        {
            var ifStatement = new ConditionalStatement();
            ifStatement.Condition = condition;

            return new IfStatementOptions(ifStatement);
        }
开发者ID:jamarchist,项目名称:SharpMock,代码行数:7,代码来源:IfStatementBuilder.cs


示例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");
            }
        }
开发者ID:ajlopez,项目名称:AjScript,代码行数:35,代码来源:CompareExpression.cs


示例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;
        }
开发者ID:anukat2015,项目名称:sones,代码行数:41,代码来源:QueryPlanManager.cs


示例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)));
        }
开发者ID:AndreyTretyak,项目名称:SpreadsheetSimulator,代码行数:26,代码来源:SpreadsheetReaderTests.cs


示例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;
 }
开发者ID:priaonehaha,项目名称:sprocketcms,代码行数:27,代码来源:BinaryExpressions.cs


示例11: AdditionNonterminalExpression

 public AdditionNonterminalExpression(
     IExpression expr1,
     IExpression expr2)
 {
     _expr1 = expr1;
       _expr2 = expr2;
 }
开发者ID:Ni2014,项目名称:TheBeautyOfDesignPatterns,代码行数:7,代码来源:Implementation.cs


示例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);
        }
开发者ID:parsnips,项目名称:Expressions,代码行数:26,代码来源:BoundExpression.cs


示例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;
            }
        }
开发者ID:Refandler,项目名称:PythonSharp,代码行数:27,代码来源:CompareExpression.cs


示例14: InstanceCreationExpression

 public InstanceCreationExpression(string type, int row, int col, IExpression arraySize = null)
     : base(row, col)
 {
     CreatedTypeName = type;
     ArraySize = arraySize;
     IsArrayCreation = arraySize != null;
 }
开发者ID:Lateks,项目名称:MiniJavaCompiler,代码行数:7,代码来源:InstanceCreationExpression.cs


示例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);
        }
开发者ID:parsnips,项目名称:Expressions,代码行数:32,代码来源:Compiler.cs


示例16: DmlSelectStatement

 /// <exception cref="System.SqlSyntaxErrorException" />
 public DmlSelectStatement(SelectOption option,
                           IList<Pair<IExpression, string>> selectExprList,
                           TableReferences tables,
                           IExpression where,
                           GroupBy group,
                           IExpression having,
                           OrderBy order,
                           Limit limit)
 {
     if (option == null)
     {
         throw new ArgumentException("argument 'option' is null");
     }
     Option = option;
     if (selectExprList == null || selectExprList.IsEmpty())
     {
         this.selectExprList = new List<Pair<IExpression, string>>(0);
     }
     else
     {
         this.selectExprList = EnsureListType(selectExprList);
     }
     Tables = tables;
     Where = where;
     Group = group;
     Having = having;
     Order = order;
     Limit = limit;
 }
开发者ID:tupunco,项目名称:Tup.Cobar4Net,代码行数:30,代码来源:DMLSelectStatement.cs


示例17: UnaryExpression

 /// <summary>
 /// Initializes a new instance of the <see cref="UnaryExpression"/> class.
 /// </summary>
 /// <param name="expression">The expression.</param>
 /// <exception cref="System.ArgumentNullException">expression</exception>
 protected UnaryExpression(IExpression expression)
 {
     if (expression == null)
         throw new ArgumentNullException("expression");
     this.Expression = expression;
     this.Type = expression.Type;
 }
开发者ID:JaCraig,项目名称:PNZR,代码行数:12,代码来源:UnaryExpression.cs


示例18: Not

		/// <summary>Optimizations: !(Bool)-&gt;(!Bool), !!X-&gt;X, !(X==Bool)-&gt;(X==!Bool)
		/// 	</summary>
		public virtual IExpression Not(IExpression expr)
		{
			if (expr.Equals(BoolConstExpression.True))
			{
				return BoolConstExpression.False;
			}
			if (expr.Equals(BoolConstExpression.False))
			{
				return BoolConstExpression.True;
			}
			if (expr is NotExpression)
			{
				return ((NotExpression)expr).Expr();
			}
			if (expr is ComparisonExpression)
			{
				ComparisonExpression cmpExpr = (ComparisonExpression)expr;
				if (cmpExpr.Right() is ConstValue)
				{
					ConstValue rightConst = (ConstValue)cmpExpr.Right();
					if (rightConst.Value() is bool)
					{
						bool boolVal = (bool)rightConst.Value();
						// new Boolean() instead of Boolean.valueOf() for .NET conversion
						return new ComparisonExpression(cmpExpr.Left(), new ConstValue(!boolVal), cmpExpr
							.Op());
					}
				}
			}
			return new NotExpression(expr);
		}
开发者ID:erdincay,项目名称:db4o,代码行数:33,代码来源:ExpressionBuilder.cs


示例19: Simplify

        /// <summary>
        /// Simplifies the <paramref name="expression"/>.
        /// </summary>
        /// <param name="expression">A expression to simplify.</param>
        /// <returns>A simplified expression.</returns>
        public IExpression Simplify(IExpression expression)
        {
            IExpression exp = _Simplify(expression);
            exp.Parent = null;

            return exp;
        }
开发者ID:smwentum,项目名称:xFunc,代码行数:12,代码来源:Simplifier.cs


示例20: Or

		/// <summary>Optimizations: X||t-&gt;t, f||X-&gt;X, X||X-&gt;X, X||!X-&gt;t</summary>
		public virtual IExpression Or(IExpression left, IExpression right)
		{
			if (left.Equals(BoolConstExpression.True) || right.Equals(BoolConstExpression.True
				))
			{
				return BoolConstExpression.True;
			}
			if (left.Equals(BoolConstExpression.False))
			{
				return right;
			}
			if (right.Equals(BoolConstExpression.False))
			{
				return left;
			}
			if (left.Equals(right))
			{
				return left;
			}
			if (Negatives(left, right))
			{
				return BoolConstExpression.True;
			}
			return new OrExpression(left, right);
		}
开发者ID:erdincay,项目名称:db4o,代码行数:26,代码来源:ExpressionBuilder.cs



注:本文中的IExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IExpressionGraph类代码示例发布时间:2022-05-24
下一篇:
C# IExpr类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap