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


C# RubyMethodAttributes类代码示例

本文整理汇总了C#中RubyMethodAttributes的典型用法代码示例。如果您正苦于以下问题:C# RubyMethodAttributes类的具体用法?C# RubyMethodAttributes怎么用?C# RubyMethodAttributes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RubyMethodAttributes类属于命名空间,在下文中一共展示了RubyMethodAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetVisibility

        private static RubyModule/*!*/ SetVisibility(RubyScope/*!*/ scope, object/*!*/ self, string/*!*/[]/*!*/ methodNames, RubyMethodAttributes attributes) {
            Assert.NotNull(scope, self, methodNames);
            RubyModule module;

            // MRI: Method is searched in the class of self (Object), not in the main singleton class.
            // IronRuby specific: If we are in a top-level scope with redirected method lookup module we use that module (hosted scopes).
            var topScope = scope.Top.GlobalScope.TopLocalScope;
            if (scope == topScope && topScope.MethodLookupModule != null) {
                module = topScope.MethodLookupModule;
            } else {
                module = scope.RubyContext.GetClassOf(self);
            }
            ModuleOps.SetMethodAttributes(scope, module, methodNames, attributes);
            return module;
        }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:15,代码来源:SingletonOps.cs

示例2: VisibilityContext

 public VisibilityContext(RubyMethodAttributes mask)
 {
     Class = null;
     Visible = mask;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:5,代码来源:VisibilityContext.cs

示例3: RubyMethodAttribute

        public RubyMethodAttribute(string/*!*/ name, RubyMethodAttributes methodAttributes)
            : base()
        {
            ContractUtils.RequiresNotNull(name, "name");

            _name = name;
            _methodAttributes = methodAttributes;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:8,代码来源:Attributes.cs

示例4: SetVisibility

 private static RubyModule/*!*/ SetVisibility(RubyScope/*!*/ scope, object/*!*/ self, object[]/*!*/ methodNames, RubyMethodAttributes attributes) {
     Assert.NotNull(scope, self, methodNames);
     RubyClass cls = scope.RubyContext.GetClassOf(self);
     ModuleOps.SetMethodAttributes(scope, cls, methodNames, attributes);
     return cls;
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:6,代码来源:SingletonOps.cs

示例5: GetMethods

        internal static RubyArray/*!*/ GetMethods(RubyModule/*!*/ self, bool inherited, RubyMethodAttributes attributes,
            IEnumerable<string> foreignMembers) {

            var result = new RubyArray();
            using (self.Context.ClassHierarchyLocker()) {
                self.ForEachMember(inherited, attributes, foreignMembers, (name, module, member) => {
                    if (member.IsInteropMember && (module.Restrictions & ModuleRestrictions.NoNameMapping) == 0 && RubyUtils.HasMangledName(name)) {
                        if (Tokenizer.IsMethodName(name) || Tokenizer.IsOperatorName(name)) {
                            result.Add(new ClrName(name));
                        }
                    } else {
                        result.Add(self.Context.StringifyIdentifier(name));
                    }
                });
            }
            return result;
        }
开发者ID:jschementi,项目名称:iron,代码行数:17,代码来源:ModuleOps.cs

示例6: SetMethodAttributes

        internal static void SetMethodAttributes(RubyScope/*!*/ scope, RubyModule/*!*/ module, object[]/*!*/ methodNames, RubyMethodAttributes attributes) {
            ContractUtils.RequiresNotNull(scope, "scope");
            ContractUtils.RequiresNotNull(methodNames, "methodNames");

            if (methodNames.Length == 0) {
                scope.GetMethodAttributesDefinitionScope().MethodAttributes = attributes;
            } else {
                foreach (string methodName in Protocols.CastToSymbols(scope.RubyContext, methodNames)) {
                    RubyMemberInfo method = module.ResolveMethodFallbackToObject(methodName, true);
                    if (method == null) {
                        throw RubyExceptions.CreateNameError(RubyExceptions.FormatMethodMissingMessage(scope.RubyContext, module, methodName));
                    }

                    if ((attributes & RubyMethodAttributes.ModuleFunction) == RubyMethodAttributes.ModuleFunction) {
                        module.AddModuleFunction(scope.RubyContext, methodName, method);
                    } else {
                        module.SetMethodVisibility(scope.RubyContext, methodName, method, (RubyMethodVisibility)(attributes & RubyMethodAttributes.VisibilityMask));
                    }
                }
            }
        }
开发者ID:aslakhellesoy,项目名称:ironruby,代码行数:21,代码来源:ModuleOps.cs

示例7: GetMethods

 private static RubyArray/*!*/ GetMethods(RubyContext/*!*/ context, object self, bool inherited, RubyMethodAttributes attributes) {
     RubyClass immediateClass = context.GetImmediateClassOf(self);
     return ModuleOps.GetMethods(immediateClass, inherited, attributes);
 }
开发者ID:aceptra,项目名称:ironruby,代码行数:4,代码来源:KernelOps.cs

示例8: ForEachMember

 public void ForEachMember(bool inherited, RubyMethodAttributes attributes, Action<string/*!*/, RubyModule/*!*/, RubyMemberInfo/*!*/>/*!*/ action) {
     ForEachMember(inherited, attributes, null, action);
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:3,代码来源:RubyModule.cs

示例9: GetMethods

 internal static RubyArray/*!*/ GetMethods(RubyModule/*!*/ self, bool inherited, RubyMethodAttributes attributes) {
     return GetMethods(self, inherited, attributes, null);
 }
开发者ID:atczyc,项目名称:ironruby,代码行数:3,代码来源:ModuleOps.cs

示例10: SetMethodAttributes

        internal static void SetMethodAttributes(RubyModule/*!*/ module, string/*!*/[]/*!*/ methodNames, RubyMethodAttributes attributes) {
            var context = module.Context;

            bool isModuleFunction = (attributes & RubyMethodAttributes.ModuleFunction) == RubyMethodAttributes.ModuleFunction;
            var instanceVisibility = isModuleFunction ? RubyMethodVisibility.Private : 
                (RubyMethodVisibility)(attributes & RubyMethodAttributes.VisibilityMask);

            foreach (string methodName in methodNames) {
                RubyMemberInfo method;

                // we need to define new methods one by one since the method_added events can define a new method that might be used here:
                using (context.ClassHierarchyLocker()) {
                    MethodLookup options = MethodLookup.FallbackToObject;
                    if (!isModuleFunction) {
                        options |= MethodLookup.ReturnForwarder;
                    }

                    method = module.ResolveMethodNoLock(methodName, VisibilityContext.AllVisible, options).Info;
                    if (method == null) {
                        throw RubyExceptions.CreateNameError(RubyExceptions.FormatMethodMissingMessage(context, module, methodName));
                    }

                    // MRI only adds method to the target module if visibility differs:
                    if (method.Visibility != instanceVisibility) {
                        module.SetVisibilityNoEventNoLock(context, methodName, method, instanceVisibility);
                    }

                    if (isModuleFunction) {
                        module.SetModuleFunctionNoEventNoLock(context, methodName, method);
                    }
                }

                if (method.Visibility != instanceVisibility) {
                    module.MethodAdded(methodName);
                }

                if (isModuleFunction) {
                    module.SingletonClass.MethodAdded(methodName);
                }
            }
        }
开发者ID:atczyc,项目名称:ironruby,代码行数:41,代码来源:ModuleOps.cs

示例11: GetMethods

        internal static RubyArray/*!*/ GetMethods(RubyModule/*!*/ self, bool inherited, RubyMethodAttributes attributes,
            IEnumerable<string> foreignMembers) {

            var result = new RubyArray();
            var symbolicNames = self.Context.RubyOptions.Compatibility > RubyCompatibility.Ruby18;

            using (self.Context.ClassHierarchyLocker()) {
                self.ForEachMember(inherited, attributes, foreignMembers, delegate(string/*!*/ name, RubyMemberInfo member) {
                    result.Add(CreateMethodName(name, symbolicNames));
                });
            }
            return result;
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:13,代码来源:ModuleOps.cs

示例12: RubyScope

 // other scopes:
 protected RubyScope(RubyScope/*!*/ parent, RuntimeFlowControl/*!*/ runtimeFlowControl, object selfObject) {
     Assert.NotNull(parent);
     _parent = parent;
     _top = parent.Top;
     _selfObject = selfObject;
     _runtimeFlowControl = runtimeFlowControl;
     _methodAttributes = RubyMethodAttributes.PrivateInstance;
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:9,代码来源:RubyScope.cs

示例13: GetMethods

 private Dictionary<string, RubyMemberInfo> GetMethods(RubyMethodAttributes attributes) {
     // TODO: custom view for methods, sorted
     var result = new Dictionary<string, RubyMemberInfo>();
     using (_obj.Context.ClassHierarchyLocker()) {
         _obj.ForEachMember(false, attributes | RubyMethodAttributes.VisibilityMask, (name, _, info) => {
             result[name] = info;
         });
     }
     return result;
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:10,代码来源:RubyModule.cs

示例14: GetMethodDefinitions

        /// <summary>
        /// メソッド定義情報を取得する。
        /// </summary>
        /// <param name="constant">モジュールまたはクラスのRubyオブジェクト。</param>
        /// <param name="attributes">メソッド取得対象を表すスイッチ。</param>
        /// <param name="objectDefinition">オブジェクト定義のインスタンス。</param>
        /// <param name="singleton">シングルトンメソッドか?</param>
        private static void GetMethodDefinitions(
            RubyModule constant,
            RubyMethodAttributes attributes,
            RubyObjectDefinition objectDefinition,
            bool singleton)
        {
            constant.ForEachMember(false, attributes | RubyMethodAttributes.VisibilityMask, (methodName, module, memberInfo) =>
            {
                if (memberInfo is RubyAttributeAccessorInfo)
                {
                    var accessorInfo = (RubyAttributeAccessorInfo)memberInfo;
                    var accessorName = methodName;

                    if (accessorInfo is RubyAttributeWriterInfo)
                    {
                        accessorName = accessorName.Substring(0, accessorName.Length - 1);
                    }

                    var accessorDefinition = (
                        from a in objectDefinition.Accessors
                        where a.Name == accessorName
                        select a
                    ).FirstOrDefault();

                    if (accessorDefinition == null)
                    {
                        accessorDefinition = new RubyAccessorDefinition()
                        {
                            Name = accessorName
                        };

                        objectDefinition.Accessors.Add(accessorDefinition);
                    }

                    if (accessorInfo is RubyAttributeWriterInfo)
                    {
                        accessorDefinition.Writable = true;
                    }
                    else if (accessorInfo is RubyAttributeReaderInfo)
                    {
                        accessorDefinition.Readable = true;
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
                else if (memberInfo is RubyMethodInfo)
                {
                    var methodInfo = (RubyMethodInfo)memberInfo;

                    var methodDefinition = new RubyMethodDefinition()
                    {
                        Name = methodName,
                        Singleton = singleton
                    };

                    foreach (LocalVariable argument in methodInfo.Parameters.Mandatory)
                    {
                        methodDefinition.Arguments.Add(
                            new RubyMethodArgumentDefinition()
                            {
                                Name = argument.Name,
                                Optional = false
                            }
                        );
                    }
                    foreach (SimpleAssignmentExpression argument in methodInfo.Parameters.Optional)
                    {
                        var argumentDefinition = new RubyMethodArgumentDefinition()
                        {
                            Name = ((LocalVariable)argument.Left).Name,
                            Optional = true
                        };

                        if (argument.Right is Literal)
                        {
                            argumentDefinition.DefaultValue = ((Literal)argument.Right).Value;
                        }
                        else if (argument.Right is ClassVariable)
                        {
                            argumentDefinition.DefaultValue = ((ClassVariable)argument.Right).Name;
                            argumentDefinition.ClassVariable = true;
                        }

                        methodDefinition.Arguments.Add(argumentDefinition);
                    }

                    objectDefinition.Methods.Add(methodDefinition);
                }
                else
                {
                    throw new NotImplementedException();
//.........这里部分代码省略.........
开发者ID:RaTTiE,项目名称:Warlock-core,代码行数:101,代码来源:RubyDefinition.cs

示例15: GetMethods

 internal static RubyArray/*!*/ GetMethods(RubyModule/*!*/ self, bool inherited, RubyMethodAttributes attributes) {
     var result = new RubyArray();
     self.ForEachMember(inherited, attributes, delegate(string/*!*/ name, RubyMemberInfo/*!*/ member) {
         result.Add(MutableString.Create(name));
     });
     return result;
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:7,代码来源:ModuleOps.cs


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