public bool Login(Password password) { if (password is null) { throw new ArgumentNullException(nameof(password)); } if (!Exists) { throw new InvalidOperationException("Storage does not exist."); } if (LoggedIn) { throw new InvalidOperationException("You are already logged in."); } try { _password = password; Read(); LoggedInChanged?.Invoke(this, EventArgs.Empty); return(true); } catch { _password = null; return(false); } }
public void Logout() { if (!LoggedIn) { throw new InvalidOperationException("You are not logged in"); } _password = null; LoggedInChanged?.Invoke(this, EventArgs.Empty); }