当前位置: 首页>>代码示例>>C#>>正文


C# RubyModule.AddMethod方法代码示例

本文整理汇总了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;
        }
开发者ID:aslakhellesoy,项目名称:ironruby,代码行数:11,代码来源:ModuleOps.cs

示例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);
     }
 }
开发者ID:ExpertsInside,项目名称:IronSP,代码行数:13,代码来源:LibraryInitializer.cs

示例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;
        }
开发者ID:atczyc,项目名称:ironruby,代码行数:8,代码来源:ModuleOps.cs

示例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));
            }
        }
开发者ID:atczyc,项目名称:ironruby,代码行数:19,代码来源:ModuleOps.cs

示例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;
        }
开发者ID:aceptra,项目名称:ironruby,代码行数:7,代码来源:ModuleOps.cs


注:本文中的IronRuby.Builtins.RubyModule.AddMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。