Esempio n. 1
0
 /// <summary>
 /// Called when the repository content is changed
 /// </summary>
 protected void RaiseItemsChanged(object sender, RepositoryChangeEventArgs <TModel> args)
 {
     ItemsChanged?.Invoke(this, args);
 }
Esempio n. 2
0
 /// <summary>
 /// Updates the collection base on the operation type
 /// </summary>
 /// <typeparam name="T"></typeparam>
 public static void Update <T>(this IList <T> collection, object sender, RepositoryChangeEventArgs <T> args)
 {
     collection.Update(args);
 }
Esempio n. 3
0
 /// <summary>
 /// Updates the collection base on the operation type
 /// </summary>
 /// <typeparam name="T"></typeparam>
 public static void Update <T>(this IList <T> collection, RepositoryChangeEventArgs <T> args)
 {
     collection.Update(args.OperationType, args.Item);
 }
Esempio n. 4
0
 private static void UpdateCollectionOnRepositoryChange <T, TKey, TTarget>(IList <TTarget> collection, ItemLocator <T, TTarget> locator, RepositoryChangeEventArgs <T> e, TTarget target) where T : IUniqueObject <TKey>
 {
     if (e.OperationType == OperationType.Add)
     {
         collection.Add(target);
     }
     else
     {
         var original = locator(e.Item);
         if (e.OperationType == OperationType.Edit)
         {
             collection.Update(target, p => p.Equals(original));
         }
         else if (e.OperationType == OperationType.Delete)
         {
             collection.Remove(original);
         }
     }
 }