예제 #1
0
        public CollectionSnapshotLookup TakeCollectionSnapshots(object entity)
        {
            CollectionSnapshotLookup snapshots = new CollectionSnapshotLookup();

            foreach (var configuration in collections.Values)
            {
                if (configuration.IsValueSource(entity))
                {
                    object collection = configuration.GetCollectionCopy(entity);
                    snapshots.Add(configuration.Property, collection);
                }
            }
            return(snapshots);
        }
예제 #2
0
        internal ICollectionChange <TElement> GetCollectionChanges <TElement>(Expression <Func <TEntity, ICollection <TElement> > > accessor, CollectionSnapshotLookup original, TEntity updated, ElementState state)
        {
            PropertyInfo property = ChangeDetector.GetProperty(accessor);

            return(detector.GetCollectionChanges <TElement>(property, original, updated, state));
        }
예제 #3
0
        public ICollectionChange <TElement> GetCollectionChanges <TElement>(PropertyInfo property, CollectionSnapshotLookup original, object updated, ElementState state)
        {
            ICollectionConfiguration configuration;

            if (!collections.TryGetValue(property, out configuration))
            {
                return(null);
            }
            var typedConfiguration = (CollectionConfiguration <TElement>)configuration;
            var originalCollection = original.GetSnapshot <TElement>(property);
            var updatedCollection  = typedConfiguration.GetCollection(updated);
            CollectionChangeDetector <TElement> detector = new CollectionChangeDetector <TElement>(typedConfiguration.Comparer);
            var changeCollection = detector.GetChanges(originalCollection, updatedCollection, state);

            return(new CollectionChange <TElement>(property, typedConfiguration.DiplayName, changeCollection));
        }