private void TrackProperty(IChangeTrackableObject trackableObject, string propertyName = null, PropertyInfo property = null) { Contract.Assert(() => ChangeTrackingContext.ChangeTracker != null); DynamicObject dynamicObject = trackableObject as DynamicObject; property = property ?? trackableObject.GetType().GetProperty(propertyName, DefaultBindingFlags); if (dynamicObject == null || (property != null && property.IsPropertyOfDynamicObject())) { PropertyInfo cachedProperty; if (!CachedProperties.TryGetValue(propertyName, out cachedProperty)) { CachedProperties.Add ( propertyName, property ); } ChangeTrackingContext.ChangeTracker.AddOrUpdateTracking(cachedProperty ?? property, trackableObject); } else { ChangeTrackingContext.ChangeTracker.AddOrUpdateTracking(propertyName, dynamicObject); } }
public static PropertyInfo[] GetPropertiesCached(this Type type) { if (!CachedProperties.ContainsKey(type)) { CachedProperties.Add(type, type.GetProperties()); } return(CachedProperties[type]); }