IronRuby.Builtins.RubyModule.ForEachConstant C# (CSharp) Method

ForEachConstant() public method

public ForEachConstant ( bool inherited, Func action ) : void
inherited bool
action Func
return void
        public void ForEachConstant(bool inherited, Func<RubyModule/*!*/, string/*!*/, object, bool>/*!*/ action) {
            Context.RequiresClassHierarchyLock();

            ForEachAncestor(inherited, delegate(RubyModule/*!*/ module) {
                // notification that we entered the module (it could have no constant):
                if (action(module, null, Missing.Value)) return true;

                return module.EnumerateConstants(action);
            });
        }

Usage Example

Exemplo n.º 1
0
        public static RubyArray /*!*/ GetDefinedConstants(RubyModule /*!*/ self)
        {
            var visited = new Dictionary <string, bool>();
            var result  = new RubyArray();

            bool hideGlobalConstants = !self.IsObjectClass;

            using (self.Context.ClassHierarchyLocker()) {
                self.ForEachConstant(true, delegate(RubyModule /*!*/ module, string name, object value) {
                    if (name == null)
                    {
                        // terminate enumeration when Object is reached
                        return(hideGlobalConstants && module.IsObjectClass);
                    }

                    if (!visited.ContainsKey(name))
                    {
                        if (Tokenizer.IsConstantName(name, true))
                        {
                            result.Add(self.Context.StringifyIdentifier(name));
                        }
                        visited.Add(name, true);
                    }
                    return(false);
                });
            }

            return(result);
        }
All Usage Examples Of IronRuby.Builtins.RubyModule::ForEachConstant
RubyModule