/// <summary> /// Updates the current account for the extension. This method will also invalidate the project /// it is up to the caller to select an appropriate one. /// </summary> /// <param name="account"></param> public void UpdateCurrentAccount(UserAccount account) { if (CurrentAccount?.AccountName != account?.AccountName) { CurrentAccount = account; CurrentProjectId = null; CurrentProjectNumericId = null; InvalidateProjectList(); UpdateDefaultCredentials(); CurrentAccountChanged?.Invoke(this, EventArgs.Empty); } }
/// <summary> /// Resets the credentials state to the account with the given <paramref name="accountName"/> and the /// given <paramref name="projectId"/>. /// If <paramref name="accountName"/> cannot be found in the store then the credentials will be reset /// to empty. /// </summary> /// <param name="accountName">The name of the account to make current.</param> /// <param name="projectId">The projectId to make current.</param> public void ResetCredentials(string accountName, string projectId) { IUserAccount newCurrentAccount = GetAccount(accountName); if (newCurrentAccount != null) { CurrentAccount = newCurrentAccount; CurrentProjectId = projectId; CurrentProjectNumericId = null; } else { Debug.WriteLine($"Unknown account: {accountName}"); CurrentAccount = null; CurrentProjectId = null; CurrentProjectNumericId = null; } UpdateDefaultCredentials(); CurrentAccountChanged?.Invoke(this, EventArgs.Empty); CurrentProjectIdChanged?.Invoke(this, EventArgs.Empty); }