本文整理汇总了C#中System.Dynamic.InvokeBinder.FallbackInvoke方法的典型用法代码示例。如果您正苦于以下问题:C# InvokeBinder.FallbackInvoke方法的具体用法?C# InvokeBinder.FallbackInvoke怎么用?C# InvokeBinder.FallbackInvoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Dynamic.InvokeBinder
的用法示例。
在下文中一共展示了InvokeBinder.FallbackInvoke方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bind
public static DynamicMetaObject/*!*/ Bind(RubyContext/*!*/ context, InvokeBinder/*!*/ binder,
RubyMetaObject/*!*/ target, DynamicMetaObject/*!*/[]/*!*/ args, Action<MetaObjectBuilder, CallArguments>/*!*/ buildInvoke) {
RubyCallSignature callSignature;
if (RubyCallSignature.TryCreate(binder.CallInfo, out callSignature)) {
return binder.FallbackInvoke(target, args);
}
var metaBuilder = new MetaObjectBuilder();
buildInvoke(metaBuilder, new CallArguments(target.CreateMetaContext(), target, args, callSignature));
return metaBuilder.CreateMetaObject(binder);
}
示例2: BindInvoke
public override DynamicMetaObject/*!*/ BindInvoke(InvokeBinder/*!*/ action, DynamicMetaObject/*!*/[]/*!*/ args) {
RubyCallSignature callSignature;
if (RubyCallSignature.TryCreate(action.Arguments, out callSignature)) {
return action.FallbackInvoke(this, args);
}
var metaBuilder = new MetaObjectBuilder();
var context = new DynamicMetaObject(
Methods.GetContextFromBlockParam.OpCall(AstUtils.Convert(Expression, typeof(BlockParam))),
BindingRestrictions.Empty,
RubyOps.GetContextFromBlockParam((BlockParam)Value)
);
BlockParam.SetCallActionRule(metaBuilder, new CallArguments(context, this, args, callSignature));
return metaBuilder.CreateMetaObject(action, args);
}
示例3: BindInvoke
public override MetaObject/*!*/ BindInvoke(InvokeBinder/*!*/ action, MetaObject/*!*/[]/*!*/ args) {
RubyCallSignature callSignature;
if (RubyCallSignature.TryCreate(action.Arguments, out callSignature)) {
return action.FallbackInvoke(this, args);
}
var self = (RubyMethod)Value;
var context = new MetaObject(
Methods.GetContextFromMethod.OpCall(AstUtils.Convert(Expression, typeof(RubyMethod))),
Restrictions.Empty,
RubyOps.GetContextFromMethod(self)
);
var metaBuilder = new MetaObjectBuilder();
Method.SetRuleForCall(metaBuilder, new CallArguments(context, this, args, callSignature));
return metaBuilder.CreateMetaObject(action, args);
}
示例4: BindInvoke
public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args) {
if (IsOverridden("TryInvoke")) {
return CallMethodWithResult("TryInvoke", binder, DynamicMetaObject.GetExpressions(args), (e) => binder.FallbackInvoke(this, args, e));
}
return base.BindInvoke(binder, args);
}
示例5: BindInvoke
/// <summary>
/// Performs the binding of the dynamic invoke operation.
/// </summary>
/// <param name="binder">An instance of the <see cref="InvokeBinder"/> that represents the details of the dynamic operation.</param>
/// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the invoke operation.</param>
/// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
public virtual DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args) {
ContractUtils.RequiresNotNull(binder, "binder");
return binder.FallbackInvoke(this, args);
}
示例6: BindInvoke
public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
{
// TODO: Implement using InvokeAttribute
DynamicMetaObject ret;
if (_type.HandleInvoke(binder, this, args, out ret))
return ret;
CodeContext context;
Expression contextExpression;
if (args.Length == binder.CallInfo.ArgumentCount + 1)
{
context = (CodeContext)args[0].Value;
contextExpression = args[0].Expression;
args = ArrayUtils.RemoveFirst(args);
}
Debug.Assert(args.Length == binder.CallInfo.ArgumentCount);
var fallback = binder.FallbackInvoke(this, args, ret);
BindingRestrictions restrictions = fallback.Restrictions.Merge(BindingRestrictions.GetTypeRestriction(Expression, LimitType));
foreach (var arg in args)
restrictions = restrictions.Merge(BindingRestrictions.GetTypeRestriction(arg.Expression, arg.LimitType));
int normalArgCount = binder.CallInfo.ArgumentCount - binder.CallInfo.ArgumentNames.Count;
List<Expression> normalArgs = new List<Expression>();
for (var i = 0; i < normalArgCount; i++)
normalArgs.Add(EnsureObject(args[i].Expression));
var addMethod = typeof(Dictionary<string, object>).GetMethod("Add");
List<ElementInit> namedArgs = new List<ElementInit>();
for (var i = 0; i < binder.CallInfo.ArgumentNames.Count; i++)
{
namedArgs.Add(
Expression.ElementInit(
addMethod,
Expression.Constant(binder.CallInfo.ArgumentNames[i], typeof(string)),
EnsureObject(args[normalArgCount + i].Expression)
)
);
}
var dictExpr = namedArgs.Count > 0 ?
(Expression)Expression.ListInit(
Expression.New(typeof(Dictionary<string, object>)),
namedArgs
) : Expression.New(typeof(Dictionary<string, object>));
return new DynamicMetaObject(
AssertImplemented(
Expression.Call(
Expression.Constant(_type, typeof(TotemType)),
TotemType.MissingInvokeInfo,
Expression,
Expression.NewArrayInit(
typeof(object),
normalArgs
),
dictExpr
),
fallback.Expression
),
restrictions
);
}
示例7: BindInvoke
public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
{
Fallback fallback = null;
if (!this.IsOverridden("TryInvoke"))
{
return base.BindInvoke(binder, args);
}
if (fallback == null)
{
fallback = e => binder.FallbackInvoke(this, args, e);
}
return this.CallMethodWithResult("TryInvoke", binder, GetArgArray(args), fallback);
}
示例8: BindInvoke
/// <summary>
/// Performs the binding of the dynamic invoke operation.
/// </summary>
/// <param name="binder">
/// An instance of the <see cref="T:System.Dynamic.InvokeBinder" /> that represents the details of the dynamic operation.
/// </param>
/// <param name="args">
/// An array of <see cref="T:System.Dynamic.DynamicMetaObject" /> instances - arguments to the invoke operation.
/// </param>
/// <returns>
/// The new <see cref="T:System.Dynamic.DynamicMetaObject" /> representing the result of the binding.
/// </returns>
public override DynamicMetaObject BindInvoke( InvokeBinder binder, DynamicMetaObject[] args )
{
return ApplyBinding( meta => meta.BindInvoke( binder, args ),
( target, errorSuggestion ) => binder.FallbackInvoke( target, args, errorSuggestion ) );
}
示例9: BindInvoke
public override DynamicMetaObject BindInvoke( InvokeBinder binder, DynamicMetaObject[] args )
{
return binder.FallbackInvoke( _baseMetaObject,
args,
AddTypeRestrictions( _metaObject.BindInvoke( binder, args ) ) );
}