Esempio n. 1
0
            internal ExtensionPropertyTracker AddPropertyInfo(string/*!*/ propName, MethodInfo get, MethodInfo set) {
                MethodInfo mi = get ?? set;

                List<ExtensionPropertyTracker> trackers;
                if (!_properties.TryGetValue(propName, out trackers)) {
                    _properties[propName] = trackers = new List<ExtensionPropertyTracker>();
                }

                ExtensionPropertyTracker res;
                for (int i = 0; i < trackers.Count; i++) {
                    if (trackers[i].DeclaringType == mi.DeclaringType) {
                        trackers[i] = res = new ExtensionPropertyTracker(
                            propName,
                            get ?? trackers[i].GetGetMethod(),
                            set ?? trackers[i].GetSetMethod(),
                            null,
                            mi.DeclaringType
                        );
                        return res;
                    }
                }

                trackers.Add(
                    res = new ExtensionPropertyTracker(
                        propName,
                        get,
                        set,
                        null,
                        mi.DeclaringType
                    )
                );

                return res;
            }
Esempio n. 2
0
        private static ExtensionPropertyTracker AddPropertyInfo(string/*!*/ propName, MethodInfo get, MethodInfo set) {
            MethodInfo mi = get ?? set;
            Type baseType = mi.DeclaringType.BaseType;

            Dictionary<string, List<ExtensionPropertyTracker>> propInfoList;

            if (!_overriddenProperties.TryGetValue(baseType, out propInfoList)) {
                _overriddenProperties[baseType] = propInfoList = new Dictionary<string, List<ExtensionPropertyTracker>>();
            }

            List<ExtensionPropertyTracker> trackers;

            if (!propInfoList.TryGetValue(propName, out trackers)) {
                propInfoList[propName] = trackers = new List<ExtensionPropertyTracker>();
            }

            ExtensionPropertyTracker res;
            for (int i = 0; i < trackers.Count; i++) {
                if (trackers[i].DeclaringType == mi.DeclaringType) {
                    trackers[i] = res = new ExtensionPropertyTracker(
                        propName,
                        get ?? trackers[i].GetGetMethod(),
                        set ?? trackers[i].GetSetMethod(),
                        null,
                        mi.DeclaringType
                    );
                    return res;
                }
            }

            trackers.Add(
                res = new ExtensionPropertyTracker(
                    propName,
                    mi,
                    null,
                    null,
                    mi.DeclaringType
                )
            );

            return res;
        }