public Credentials GetAuthenticated(string login, string password, Guid guid)
 {
     using (var repo = new Repository())
     {
         var cred = repo.GetCredentials(login, password);
         if (cred == null)
         {
             throw new InvalidCredentialException("Неверный логин или пароль");
         }
         AllCredentials.Add(guid, cred);
         var args = new AuthenticatedArgs {Credentials = cred};
         Credentials = cred;
         OnAuthenticated(args);
         return cred;
     }
 }
 protected virtual void OnAuthenticated(AuthenticatedArgs e)
 {
     var handler = Authenticated;
     if (handler != null) handler.Invoke(this, e);
 }