本文整理汇总了C#中IronRuby.Builtins.RubyModule.ForEachConstant方法的典型用法代码示例。如果您正苦于以下问题:C# RubyModule.ForEachConstant方法的具体用法?C# RubyModule.ForEachConstant怎么用?C# RubyModule.ForEachConstant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronRuby.Builtins.RubyModule
的用法示例。
在下文中一共展示了RubyModule.ForEachConstant方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDefinedConstants
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;
}
示例2: GetDefinedConstants
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;
}
示例3: GetDefinedConstants
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;
}