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); }
public static RubyArray /*!*/ GetDefinedConstants(RubyModule /*!*/ self) { var visited = new Dictionary <string, bool>(); var result = new RubyArray(); bool hideGlobalConstants = !ReferenceEquals(self, self.Context.ObjectClass); self.ForEachConstant(true, delegate(RubyModule /*!*/ module, string name, object value) { if (name == null) { // terminate enumeration when Object is reached return(hideGlobalConstants && ReferenceEquals(module, module.Context.ObjectClass)); } if (!visited.ContainsKey(name)) { visited.Add(name, true); result.Add(MutableString.Create(name)); } return(false); }); return(result); }
public static RubyArray/*!*/ GetDefinedConstants(RubyModule/*!*/ self) { var visited = new Dictionary<string, bool>(); var result = new RubyArray(); bool hideGlobalConstants = !ReferenceEquals(self, self.Context.ObjectClass); self.ForEachConstant(true, delegate(RubyModule/*!*/ module, string name, object value) { if (name == null) { // terminate enumeration when Object is reached return hideGlobalConstants && ReferenceEquals(module, module.Context.ObjectClass); } if (!visited.ContainsKey(name)) { visited.Add(name, true); result.Add(MutableString.Create(name)); } return false; }); return result; }
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)) { visited.Add(name, true); // TODO (encoding): result.Add(MutableString.Create(name, RubyEncoding.UTF8)); } return false; }); } return result; }
public static RubyArray/*!*/ GetDefinedConstants(RubyModule/*!*/ self, [DefaultParameterValue(true)]bool inherited) { var result = new RubyArray(); if (inherited) { var visited = new Dictionary<string, bool>(); 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)) { result.Add(self.Context.StringifyIdentifier(name)); } visited.Add(name, true); } return false; }); } } else { using (self.Context.ClassHierarchyLocker()) { self.EnumerateConstants((module, name, value) => { if (Tokenizer.IsConstantName(name)) { result.Add(self.Context.StringifyIdentifier(name)); } return false; }); } } return result; }