IronRuby.Builtins.RubyClass.TryGetClrMember C# (CSharp) Method

TryGetClrMember() public method

public TryGetClrMember ( string name, Type asType, IronRuby.Runtime.Calls.RubyMemberInfo &method ) : bool
name string
asType System.Type
method IronRuby.Runtime.Calls.RubyMemberInfo
return bool
        public bool TryGetClrMember(string/*!*/ name, Type asType, out RubyMemberInfo method) {
            Debug.Assert(!_isSingletonClass);

            // Get the first class in hierarchy that represents CLR type - worse case we end up with Object.
            // Ruby classes don't represent a CLR type and hence expose no CLR members.
            RubyClass cls = this;
            while (cls.TypeTracker == null) {
                cls = cls.SuperClass;
            }

            Type type = cls.TypeTracker.Type;
            Debug.Assert(!RubyModule.IsModuleType(type));

            // Note: We don't cache results as this API is not used so frequently (e.g. for regular method dispatch).
            
            if (asType != null && !asType.IsAssignableFrom(type)) {
                throw RubyExceptions.CreateNameError(String.Format("`{0}' does not inherit from `{1}'", cls.Name, Context.GetTypeName(asType, true)));
            }

            method = null;
            using (Context.ClassHierarchyLocker()) {
                return cls.TryGetClrMember(asType ?? type, name, true, true, 0, out method);
            }
        }

Same methods

RubyClass::TryGetClrMember ( Type type, string name, bool mapNames, bool unmangleNames, BindingFlags basicBindingFlags, IronRuby.Runtime.Calls.RubyMemberInfo &method ) : bool
RubyClass::TryGetClrMember ( Type type, string name, bool mapNames, bool unmangleNames, IronRuby.Runtime.Calls.RubyMemberInfo &method ) : bool