本文整理汇总了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;
}
示例2: VisibilityContext
public VisibilityContext(RubyMethodAttributes mask)
{
Class = null;
Visible = mask;
}
示例3: RubyMethodAttribute
public RubyMethodAttribute(string/*!*/ name, RubyMethodAttributes methodAttributes)
: base()
{
ContractUtils.RequiresNotNull(name, "name");
_name = name;
_methodAttributes = methodAttributes;
}
示例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;
}
示例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;
}
示例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));
}
}
}
}
示例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);
}
示例8: ForEachMember
public void ForEachMember(bool inherited, RubyMethodAttributes attributes, Action<string/*!*/, RubyModule/*!*/, RubyMemberInfo/*!*/>/*!*/ action) {
ForEachMember(inherited, attributes, null, action);
}
示例9: GetMethods
internal static RubyArray/*!*/ GetMethods(RubyModule/*!*/ self, bool inherited, RubyMethodAttributes attributes) {
return GetMethods(self, inherited, attributes, null);
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
//.........这里部分代码省略.........
示例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;
}