示例#1
0
 public void RemoveUser(User user)
 {
     if (user == null)
     {
         var paramName = nameof(user);
         throw new ArgumentNullException(paramName);
     }
 }
示例#2
0
 private static void NullConditionalOperator()
 {
     var user = new User
     {
         Parent = CreateDefaultUser()
     };
     WriteLine(user.Parent?.Name[0]);
     WriteLine(user.Parent?.Parent?.Name);
     var viewModel = new UserListViewModel();
     viewModel.AddUser(user);
 }
示例#3
0
 public User SaveUser(User user, bool retry = true)
 {
     try
     {
         return SaveUserInternal(user, retry);
     }
     catch (RetryableException ex) when (ex.Retryable)
     {
         return SaveUser(user, false);
     }
     catch (RetryableException ex)
     {
         throw new ApplicationException();
     }
 }
示例#4
0
 public async Task<User> SaveUserAsync(User user, bool retry = true)
 {
     try
     {
         var startNew = Task.Factory.StartNew(() => SaveUserInternal(user, retry));
         return await startNew;
     }
     catch (RetryableException ex) when (ex.Retryable)
     {
         return await SaveUserAsync(user, false);
     }
     catch (Exception ex)
     {
         throw new ApplicationException();
     }
 }
示例#5
0
 private User SaveUserInternal(User user, bool retryable = true)
 {
     throw new RetryableException("Failed to save user", retryable);
     return new User();
 }
示例#6
0
 public void AddUser(User user)
 {
     userList.Add(user);
     UserAdded?.Invoke(this, user);
 }