本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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)) });
}