Example #1
0
        public static VersionedList <T> UpsertWhere <T>(this VersionedList <T> source, Func <T, bool> predicate, T item)
        {
            var index = source.IndexOf(predicate);

            if (index < 0)
            {
                return(source.Add(item));
            }

            return(source.SetItem(index, item));
        }
Example #2
0
 public static VersionedList <T> ToVersionedList <T>(this IEnumerable <T> source)
 {
     return(VersionedList <T> .Create(source));
 }
Example #3
0
 public static VersionedList <T> Upsert <T>(this VersionedList <T> source, T item)
 {
     return(source.Upsert(t => t, item));
 }
Example #4
0
        public static VersionedList <T> Upsert <T, K>(this VersionedList <T> source, Func <T, K> trackBy, T item)
        {
            var key = trackBy(item);

            return(source.UpsertWhere(t => Equals(trackBy(t), key), item));
        }