Exemplo n.º 1
0
        internal ClassMember GetItem(RuntimeContexts.RuntimeContext context, bool isStatic)
        {
            var         members = isStatic ? StaticMembers : InstanceMembers;
            ClassMember value;
            string      rename;
            string      idxget = ClassHelper.RenameIndexerGetter;
            string      idxset = ClassHelper.RenameIndexerSetter;
            var         cls    = context.Class as ClassObject;

            if (cls != null)
            {
                rename = ClassHelper.RenamePrivate(idxget, cls.Name);
                if (members.TryGetValue(rename, out value) && value is IndexerGetter)
                {
                    return(value);
                }
                rename = ClassHelper.RenamePrivate(idxset, cls.Name);
                if (members.TryGetValue(rename, out value) && value is IndexerSetter)
                {
                    return(ClassHelper.ThrowIndexerIsWriteonly());
                }
            }
            {
                rename = idxget;
                if (members.TryGetValue(rename, out value) && value is IndexerGetter)
                {
                    return(value);
                }
                rename = idxset;
                if (members.TryGetValue(rename, out value) && value is IndexerSetter)
                {
                    return(ClassHelper.ThrowIndexerIsWriteonly());
                }
            }
            if (cls == this || ClassHelper.IsExtendedFrom(this, cls) || ClassHelper.IsExtendedFrom(cls, this))
            {
                rename = ClassHelper.RenameProtected(idxget);
                if (members.TryGetValue(rename, out value) && value is IndexerGetter)
                {
                    return(value);
                }
                rename = ClassHelper.RenameProtected(idxset);
                if (members.TryGetValue(rename, out value) && value is IndexerSetter)
                {
                    return(ClassHelper.ThrowIndexerIsWriteonly());
                }
            }
            if (Super != null)
            {
                return(Super.GetItem(context, isStatic));
            }
            return(ClassHelper.ThrowIndexerNotSupported());
        }