Esempio n. 1
0
        /// <summary>
        /// Removes outdated key events from a changeset, only leaving the last relevent change for each key.
        /// </summary>
        public static IChangeSet <TObject, TKey> EnsureUniqueChanges <TObject, TKey>(this IChangeSet <TObject, TKey> input)
        {
            var changes = input
                          .GroupBy(kvp => kvp.Key)
                          .Select(g => g.Aggregate(Optional <Change <TObject, TKey> > .None, Reduce))
                          .Where(x => x.HasValue)
                          .Select(x => x.Value);

            return(new ChangeSet <TObject, TKey>(changes));
        }