Example #1
0
 internal override bool TryGetValue(CodeContext context, object instance, PythonType owner, out object value)
 {
     value = new ReflectedIndexer(this, instance);
     return(true);
 }
Example #2
0
 public ReflectedIndexer(ReflectedIndexer from, object instance)
     : base(from)
 {
     _instance = instance;
     _info     = from._info;
 }
Example #3
0
 internal override bool TryGetValue(CodeContext context, object instance, PythonType owner, out object value) {
     value = new ReflectedIndexer(this, instance);
     return true;
 }
Example #4
0
        internal static ReflectedGetterSetter GetReflectedProperty(PropertyTracker pt, MemberGroup allProperties, bool privateBinding) {
            ReflectedGetterSetter rp;
            lock (_propertyCache) {
                if (_propertyCache.TryGetValue(pt, out rp)) {
                    return rp;
                }

                NameType nt = NameType.PythonProperty;
                MethodInfo getter = FilterProtectedGetterOrSetter(pt.GetGetMethod(true), privateBinding);
                MethodInfo setter = FilterProtectedGetterOrSetter(pt.GetSetMethod(true), privateBinding);

                if ((getter != null && getter.IsDefined(typeof(PythonHiddenAttribute), true)) ||
                    setter != null && setter.IsDefined(typeof(PythonHiddenAttribute), true)) {
                    nt = NameType.Property;
                }                

                ExtensionPropertyTracker ept = pt as ExtensionPropertyTracker;
                if (ept == null) {
                    ReflectedPropertyTracker rpt = pt as ReflectedPropertyTracker;
                    Debug.Assert(rpt != null);

                    if (PythonBinder.IsExtendedType(pt.DeclaringType) ||
                        rpt.Property.IsDefined(typeof(PythonHiddenAttribute), true)) {
                        nt = NameType.Property;
                    }

                    if (pt.GetIndexParameters().Length == 0) {
                        List<MethodInfo> getters = new List<MethodInfo>();
                        List<MethodInfo> setters = new List<MethodInfo>();

                        IList<ExtensionPropertyTracker> overriddenProperties = NewTypeMaker.GetOverriddenProperties((getter ?? setter).DeclaringType, pt.Name);
                        foreach (ExtensionPropertyTracker tracker in overriddenProperties) {
                            MethodInfo method = tracker.GetGetMethod(privateBinding);
                            if (method != null) {
                                getters.Add(method);
                            }

                            method = tracker.GetSetMethod(privateBinding);
                            if (method != null) {
                                setters.Add(method);
                            }
                        }

                        foreach (PropertyTracker propTracker in allProperties) {
                            MethodInfo method = propTracker.GetGetMethod(privateBinding);
                            if (method != null) {
                                getters.Add(method);
                            }

                            method = propTracker.GetSetMethod(privateBinding);
                            if (method != null) {
                                setters.Add(method);
                            }
                        }
                        rp = new ReflectedProperty(rpt.Property, getters.ToArray(), setters.ToArray(), nt);
                    } else {
                        rp = new ReflectedIndexer(((ReflectedPropertyTracker)pt).Property, NameType.Property, privateBinding);
                    }
                } else {
                    rp = new ReflectedExtensionProperty(new ExtensionPropertyInfo(pt.DeclaringType, getter ?? setter), nt);
                }

                _propertyCache[pt] = rp;

                return rp;
            }            
        }
Example #5
0
 public ReflectedIndexer(ReflectedIndexer from, object instance)
     : base(from) {
     _instance = instance;
     _info = from._info;
 }