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


C# DynamicMetaObjectBinder.GetUpdateExpression方法代碼示例

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


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

示例1: CreateMetaObject

        internal DynamicMetaObject/*!*/ CreateMetaObject(DynamicMetaObjectBinder/*!*/ action) {
            Debug.Assert(ControlFlowBuilder == null, "Control flow required but not built");

            var expr = _error ? Ast.Throw(_result) : _result;

            if (_condition != null) {
                var deferral = action.GetUpdateExpression(typeof(object));
                expr = Ast.Condition(_condition, AstUtils.Convert(expr, typeof(object)), deferral);
            }

            if (_temps != null) {
                expr = Ast.Block(_temps, expr);
            }

            BindingRestrictions restrictions;
            if (_restriction != null) {
                restrictions = BindingRestrictions.GetExpressionRestriction(_restriction);
            } else {
                restrictions = BindingRestrictions.Empty;
            }

            return new DynamicMetaObject(expr, restrictions);
        }
開發者ID:tnachen,項目名稱:ironruby,代碼行數:23,代碼來源:MetaObjectBuilder.cs

示例2: CreateMetaObject

        internal DynamicMetaObject/*!*/ CreateMetaObject(DynamicMetaObjectBinder/*!*/ binder, Type/*!*/ returnType) {
            Debug.Assert(ControlFlowBuilder == null, "Control flow required but not built");

            var restrictions = _restrictions;
            var expr = _error ? Ast.Throw(_result, returnType) : AstUtils.Convert(_result, returnType);

            if (_condition != null) {
                var deferral = binder.GetUpdateExpression(returnType);
                expr = Ast.Condition(_condition, expr, deferral);
            }

            if (_temps != null || _initializations != null) {
                AddInitialization(expr);
                if (_temps != null) {
                    expr = Ast.Block(_temps, _initializations);
                } else {
                    expr = Ast.Block(_initializations);
                }
            }

            Clear();
            RubyBinder.DumpRule(binder, restrictions, expr);
            return new DynamicMetaObject(expr, restrictions);
        }
開發者ID:madpilot,項目名稱:ironruby,代碼行數:24,代碼來源:MetaObjectBuilder.cs

示例3: AddDynamicTestAndDefer

        internal static DynamicMetaObject/*!*/ AddDynamicTestAndDefer(DynamicMetaObjectBinder/*!*/ operation, DynamicMetaObject/*!*/ res, DynamicMetaObject/*!*/[] args, ValidationInfo typeTest, Type deferType, params ParameterExpression[] temps) {
            if (typeTest != null) {
                if (typeTest.Test != null) {
                    // add the test and a validator if persent
                    Expression defer = operation.GetUpdateExpression(deferType ?? typeof(object));

                    Type bestType = BindingHelpers.GetCompatibleType(defer.Type, res.Expression.Type);

                    res = new DynamicMetaObject(
                        Ast.Condition(
                            typeTest.Test,
                            AstUtils.Convert(res.Expression, bestType),
                            AstUtils.Convert(defer, bestType)
                        ),
                        res.Restrictions 
                    );
                }
            } 
            
            if (temps.Length > 0) {
                // finally add the scoped variables
                res = new DynamicMetaObject(
                    Ast.Block(temps, res.Expression),
                    res.Restrictions,
                    null
                );
            }

            return res;
        }
開發者ID:jschementi,項目名稱:iron,代碼行數:30,代碼來源:BindingHelpers.cs

示例4: CreateMetaObject

        internal DynamicMetaObject/*!*/ CreateMetaObject(DynamicMetaObjectBinder/*!*/ action, Type/*!*/ returnType) {
            Debug.Assert(ControlFlowBuilder == null, "Control flow required but not built");

            var expr = _error ? Ast.Throw(_result, returnType) : AstUtils.Convert(_result, returnType);

            if (_condition != null) {
                var deferral = action.GetUpdateExpression(returnType);
                expr = Ast.Condition(_condition, expr, deferral);
            }

            if (_temps != null) {
                expr = Ast.Block(_temps, expr);
            }

            RubyBinder.DumpRule(action, _restrictions, expr);
            return new DynamicMetaObject(expr, _restrictions);
        }
開發者ID:aceptra,項目名稱:ironruby,代碼行數:17,代碼來源:MetaObjectBuilder.cs

示例5: CreateMetaObject

        internal DynamicMetaObject/*!*/ CreateMetaObject(DynamicMetaObjectBinder/*!*/ action, Type/*!*/ returnType) {
            Debug.Assert(ControlFlowBuilder == null, "Control flow required but not built");

            var expr = _error ? Ast.Throw(_result, returnType) : AstUtils.Convert(_result, returnType);

            if (_condition != null) {
                var deferral = action.GetUpdateExpression(returnType);
                expr = Ast.Condition(_condition, expr, deferral);
            }

            if (_temps != null) {
                expr = Ast.Block(_temps, expr);
            }

#if DEBUG && !SILVERLIGHT && !SYSTEM_CORE
            if (RubyOptions.ShowRules) {
                var oldColor = Console.ForegroundColor;
                try {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("Rule #{0}: {1}", Interlocked.Increment(ref _ruleCounter), action);
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    var d = (_restrictions != BindingRestrictions.Empty) ? Ast.IfThen(_restrictions.ToExpression(), expr) : expr;
                    d.DumpExpression(Console.Out);
                } finally {
                    Console.ForegroundColor = oldColor;
                }
            }
#endif

            return new DynamicMetaObject(expr, _restrictions);
        }
開發者ID:m4dc4p,項目名稱:ironruby,代碼行數:31,代碼來源:MetaObjectBuilder.cs

示例6: MaybeDebase

 internal static Expression MaybeDebase(DynamicMetaObjectBinder binder, Func<Expression, Expression> generator, DynamicMetaObject target)
 {
     ParameterExpression expression;
     if (!(target.Value is PSObject))
     {
         return generator(target.Expression);
     }
     object obj2 = PSObject.Base(target.Value);
     return Expression.Block(new ParameterExpression[] { expression = Expression.Parameter(typeof(object), "value") }, new Expression[] { Expression.Assign(expression, Expression.Call(CachedReflectionInfo.PSObject_Base, target.Expression)), Expression.Condition((obj2 == null) ? ((Expression) Expression.AndAlso(Expression.Equal(expression, ExpressionCache.NullConstant), Expression.Not(Expression.Equal(target.Expression, ExpressionCache.AutomationNullConstant)))) : ((Expression) Expression.TypeEqual(expression, obj2.GetType())), generator(expression), binder.GetUpdateExpression(binder.ReturnType)) });
 }
開發者ID:nickchal,項目名稱:pash,代碼行數:10,代碼來源:PSEnumerableBinder.cs


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