本文整理汇总了C#中IronRuby.Builtins.RubyModule.ForEachMember方法的典型用法代码示例。如果您正苦于以下问题:C# RubyModule.ForEachMember方法的具体用法?C# RubyModule.ForEachMember怎么用?C# RubyModule.ForEachMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronRuby.Builtins.RubyModule
的用法示例。
在下文中一共展示了RubyModule.ForEachMember方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMethods
internal static RubyArray/*!*/ GetMethods(RubyModule/*!*/ self, bool inherited, RubyMethodAttributes attributes) {
var result = new RubyArray();
var symbolicNames = self.Context.RubyOptions.Compatibility > RubyCompatibility.Ruby18;
self.ForEachMember(inherited, attributes, delegate(string/*!*/ name, RubyMemberInfo/*!*/ member) {
if (symbolicNames) {
result.Add(SymbolTable.StringToId(name));
} else {
result.Add(MutableString.Create(name));
}
});
return result;
}
示例2: 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;
}
示例3: 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();
//.........这里部分代码省略.........
示例4: 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, (name, module, member) => {
if (member.IsInteropMember && (module.Restrictions & ModuleRestrictions.NoNameMapping) == 0 && RubyUtils.HasMangledName(name)) {
result.Add(new ClrName(name));
} else {
result.Add(CreateMethodName(name, symbolicNames));
}
});
}
return result;
}
示例5: 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;
}
示例6: 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;
}