本文整理汇总了C#中IronRuby.Builtins.RubyModule.AddMethod方法的典型用法代码示例。如果您正苦于以下问题:C# RubyModule.AddMethod方法的具体用法?C# RubyModule.AddMethod怎么用?C# RubyModule.AddMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronRuby.Builtins.RubyModule
的用法示例。
在下文中一共展示了RubyModule.AddMethod方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefineMethod
public static Proc/*!*/ DefineMethod(RubyScope/*!*/ scope, RubyModule/*!*/ self,
[DefaultProtocol]string/*!*/ methodName, [NotNull]Proc/*!*/ method) {
// MRI: ignores ModuleFunction scope flag (doesn't create singleton method).
// MRI 1.8: uses private visibility if module_function is applied (bug).
// MFI 1.9: uses public visibility as we do, unless the name is special.
var visibility = RubyUtils.GetSpecialMethodVisibility(scope.Visibility, methodName);
self.AddMethod(scope.RubyContext, methodName, Proc.ToLambdaMethodInfo(method.ToLambda(), methodName, visibility, self));
return method;
}
示例2: SetLibraryMethod
// thread-safe:
private static void SetLibraryMethod(RubyModule/*!*/ module, string/*!*/ name, RubyMemberInfo/*!*/ method, bool noEvent) {
var context = module.Context;
// trigger event only for non-builtins:
if (noEvent) {
// TODO: hoist lock?
using (context.ClassHierarchyLocker()) {
module.SetMethodNoMutateNoEventNoLock(context, name, method);
}
} else {
module.AddMethod(context, name, method);
}
}
示例3: DefineMethod
public static Proc/*!*/ DefineMethod(RubyScope/*!*/ scope, RubyModule/*!*/ self,
[DefaultProtocol, NotNull]string/*!*/ methodName, [NotNull]Proc/*!*/ block) {
var visibility = GetDefinedMethodVisibility(scope, self, methodName);
var info = Proc.ToLambdaMethodInfo(block, methodName, visibility, self);
self.AddMethod(scope.RubyContext, methodName, info);
return info.Lambda;
}
示例4: DefineAccessor
private static void DefineAccessor(RubyScope/*!*/ scope, RubyModule/*!*/ self, string/*!*/ name, bool readable, bool writable) {
// MRI: ignores ModuleFunction scope flag (doesn't create singleton methods):
if (!Tokenizer.IsVariableName(name, true)) {
throw RubyExceptions.CreateNameError("invalid attribute name `{0}'", name);
}
var varName = "@" + name;
var attributesScope = scope.GetMethodAttributesDefinitionScope();
if (readable) {
var flags = (RubyMemberFlags)RubyUtils.GetSpecialMethodVisibility(attributesScope.Visibility, name);
self.AddMethod(scope.RubyContext, name, new RubyAttributeReaderInfo(flags, self, varName));
}
if (writable) {
self.AddMethod(scope.RubyContext, name + "=", new RubyAttributeWriterInfo((RubyMemberFlags)attributesScope.Visibility, self, varName));
}
}
示例5: DefineMethod
public static Proc/*!*/ DefineMethod(RubyScope/*!*/ scope, RubyModule/*!*/ self,
[DefaultProtocol, NotNull]string/*!*/ methodName, [NotNull]Proc/*!*/ method) {
var visibility = GetDefinedMethodVisibility(scope, self, methodName);
self.AddMethod(scope.RubyContext, methodName, Proc.ToLambdaMethodInfo(method.ToLambda(), methodName, visibility, self));
return method;
}