Пример #1
0
 private static ImmutableDictionary <Guid, MyUser1> ReduceUsers(ImmutableDictionary <Guid, MyUser1> users, object action)
 {
     if (action is ActionOnUser a)
     {
         bool changed = false;
         var  user    = users[a.targetUser].Mutate(action, ReduceUser, ref changed);
         if (changed)
         {
             users = users.SetItem(user.id, user);
         }
         else
         {
             throw new MissingMethodException("Logic for action missing: " + a);
         }
     }
     if (action is ActionOnUser.AddContact add)
     {
         // The AddContact action is handled in multiple reducers (here and below in the contacts reducer of the user):
         users = users.AddOrCreate(add.newContact.id, add.newContact);
     }
     return(users);
 }