本文整理汇总了C#中RubyContext.ResolveMethod方法的典型用法代码示例。如果您正苦于以下问题:C# RubyContext.ResolveMethod方法的具体用法?C# RubyContext.ResolveMethod怎么用?C# RubyContext.ResolveMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RubyContext
的用法示例。
在下文中一共展示了RubyContext.ResolveMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryBind
public static MetaObject TryBind(RubyContext/*!*/ context, GetMemberBinder/*!*/ binder, MetaObject/*!*/ target) {
Assert.NotNull(context, target);
var metaBuilder = new MetaObjectBuilder();
var contextExpression = Ast.Constant(context);
metaBuilder.AddTargetTypeTest(target.Value, target.Expression, context, contextExpression);
RubyMemberInfo method = context.ResolveMethod(target.Value, binder.Name, true).InvalidateSitesOnOverride();
if (method != null && RubyModule.IsMethodVisible(method, false)) {
// we need to create a bound member:
metaBuilder.Result = Ast.Constant(new RubyMethod(target.Value, method, binder.Name));
} else {
// TODO:
// We need to throw an exception if we don't find method_missing so that our version update optimization works:
// This limits interop with other languages.
//
// class B CLR type with method 'foo'
// class C < B Ruby class
// x = C.new
//
// 1. x.GET("foo") from Ruby
// No method found or CLR method found -> fallback to Python
// Python might see its method foo or might just fallback to .NET,
// in any case it will add rule [1] with restriction on type of C w/o Ruby version check.
// 2. B.define_method("foo")
// This doesn't update C due to the optimization (there is no overridden method foo in C).
// 3. x.GET("foo") from Ruby
// This will not invoke the binder since the rule [1] is still valid.
//
object symbol = SymbolTable.StringToId(binder.Name);
RubyCallAction.BindToMethodMissing(metaBuilder, binder.Name,
new CallArguments(
new MetaObject(contextExpression, Restrictions.Empty, context),
new[] {
target,
new MetaObject(Ast.Constant(symbol), Restrictions.Empty, symbol)
},
RubyCallSignature.Simple(1)
),
method != null
);
}
// TODO: we should return null if we fail, we need to throw exception for now:
return metaBuilder.CreateMetaObject(binder, MetaObject.EmptyMetaObjects);
}
示例2: GetMethod
public static RubyMethod/*!*/ GetMethod(RubyContext/*!*/ context, object self, [DefaultProtocol, NotNull]string/*!*/ name) {
RubyMemberInfo info = context.ResolveMethod(self, name, VisibilityContext.AllVisible).Info;
if (info == null) {
throw RubyExceptions.CreateUndefinedMethodError(context.GetClassOf(self), name);
}
return new RubyMethod(self, info, name);
}
示例3: RespondTo
public static bool RespondTo(RubyContext/*!*/ context, object self,
[DefaultProtocol, NotNull]string/*!*/ methodName, [Optional]bool includePrivate) {
return context.ResolveMethod(self, methodName, includePrivate).Found;
}
示例4: RespondTo
public static bool RespondTo(RubyContext/*!*/ context, object self,
[DefaultProtocol, NotNull]string/*!*/ methodName, [DefaultParameterValue(null)]object includePrivate) {
return context.ResolveMethod(self, methodName, Protocols.IsTrue(includePrivate)).Found;
}