當前位置: 首頁>>代碼示例>>C#>>正文


C# Expression.IsMemoryLocationOrConstant方法代碼示例

本文整理匯總了C#中System.Linq.Expressions.Expression.IsMemoryLocationOrConstant方法的典型用法代碼示例。如果您正苦於以下問題:C# Expression.IsMemoryLocationOrConstant方法的具體用法?C# Expression.IsMemoryLocationOrConstant怎麽用?C# Expression.IsMemoryLocationOrConstant使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Linq.Expressions.Expression的用法示例。


在下文中一共展示了Expression.IsMemoryLocationOrConstant方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GenerateExpression

 private Expression GenerateExpression(Expression left, Expression right) {
     Contract.Requires(left != null);
     Contract.Requires(right != null);
     Contract.Requires(left.IsMemoryLocationOrConstant());
     Contract.Requires(right.IsMemoryLocationOrConstant());
     Contract.Ensures(Contract.Result<Expression>() != null);
     return Condition(
         ReductionExpressionGenerator.GenerateOrThrow("GREATEREQUAL", left, right),
         left,
         right
     );
 }
開發者ID:aarondandy,項目名稱:vertesaur,代碼行數:12,代碼來源:MaxExpression.cs

示例2: CreateExpression

 private Expression CreateExpression(Expression input) {
     Contract.Requires(null != input);
     Contract.Requires(input.IsMemoryLocationOrConstant());
     Contract.Ensures(Contract.Result<Expression>() != null);
     var gen = ReductionExpressionGenerator;
     var one = gen.GenerateOrThrow("1", input.Type);
     var log = gen.GenerateOrThrow("LOG",
         gen.GenerateOrThrow("DIVIDE",
             gen.GenerateOrThrow("ADD", one, input),
             gen.GenerateOrThrow("SUBTRACT", one, input)
         )
     );
     var two = gen.GenerateOrThrow("2", input.Type);
     return gen.GenerateOrThrow("DIVIDE", log, two);
 }
開發者ID:aarondandy,項目名稱:vertesaur,代碼行數:15,代碼來源:AtanhExpression.cs

示例3: CreateExpression

 private Expression CreateExpression(Expression input) {
     Contract.Requires(input != null);
     Contract.Requires(input.IsMemoryLocationOrConstant());
     Contract.Ensures(Contract.Result<Expression>() != null);
     var gen = ReductionExpressionGenerator;
     return gen.GenerateOrThrow("LOG",
         gen.GenerateOrThrow("ADD",
             gen.GenerateOrThrow("SQUAREROOT",
                 gen.GenerateOrThrow("ADD",
                     gen.GenerateOrThrow("SQUARE", input),
                     gen.GenerateOrThrow("1", input.Type)
                 )
             ),
             input
         )
     );
 }
開發者ID:aarondandy,項目名稱:vertesaur,代碼行數:17,代碼來源:AsinhExpression.cs

示例4: GenerateCompareTo

        private Expression GenerateCompareTo(IExpressionGenerationRequest request, Expression left, Expression right) {
            Contract.Requires(null != request);
            Contract.Requires(null != left);
            Contract.Requires(null != right);
            if (left.IsMemoryLocationOrConstant() && right.IsMemoryLocationOrConstant()) {
                var eq = request.TopLevelGenerator.GenerateOrThrow("EQUAL", left, right);
                var less = request.TopLevelGenerator.GenerateOrThrow("LESS", left, right);
                Contract.Assume(typeof(IComparable<>).GetGenericArguments() != null);
                Contract.Assume(typeof(IComparable<>).GetGenericArguments().Length == 1);
                Contract.Assume(typeof(IComparable<>).IsGenericTypeDefinition());
                var comparableType = typeof(IComparable<>).MakeGenericType(right.Type);

                if (left.Type.ImplementsInterface(comparableType)) {
                    var method = comparableType.GetPublicInstanceInvokableMethod(
                        "CompareTo",
                        new[] {right.Type}
                    );
                    Contract.Assume(method != null);
                    return method.BuildInstanceCallExpression(left, right);
                }

                return Expression.Condition(
                    eq,
                    Expression.Constant(0),
                    Expression.Condition(
                        less,
                        Expression.Constant(-1),
                        Expression.Constant(1)
                    )
                );
            }

            return new BlockExpressionBuilder().AddUsingMemoryLocationsOrConstants(locals => new[] {
                GenerateCompareTo(request, locals[0], locals[1])
            }, left, right).GetExpression();
        }
開發者ID:aarondandy,項目名稱:vertesaur,代碼行數:36,代碼來源:CoreExpressionGenerator.cs


注:本文中的System.Linq.Expressions.Expression.IsMemoryLocationOrConstant方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。