示例#1
0
        public IMember GetMember(IModuleContext context, string name)
        {
            if (_attrs == null)
            {
                Interlocked.CompareExchange(ref _attrs, new Dictionary <string, MemberInfo>(), null);
            }
            bool showClr = context == null || ((IronPythonModuleContext)context).ShowClr;

            if (!_attrs.TryGetValue(name, out MemberInfo member) || member.Member == null)
            {
                RemoteInterpreterProxy ri  = RemoteInterpreter;
                ObjectIdentityHandle   res = ri != null?ri.GetMember(Value, name) : default(ObjectIdentityHandle);

                if (!res.Equals(Value))
                {
                    _attrs[name] = member = new MemberInfo(_interpreter.MakeObject(res));
                }
            }

            if (!showClr)
            {
                if (!(this is IronPythonNamespace))
                {                   // namespaces always show all of their members...
                    switch (member.ClrOnly)
                    {
                    case IsClrOnly.NotChecked:
                        CreateNonClrAttrs();
                        if (_attrs.ContainsKey(name) &&
                            _attrs[name].ClrOnly == IsClrOnly.Yes)
                        {
                            return(null);
                        }
                        break;

                    case IsClrOnly.No:
                        break;

                    case IsClrOnly.Yes:
                        return(null);
                    }
                }
            }

            return(member.Member);
        }