// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // using System.Collections.Generic; using Microsoft.SqlTools.ResourceProvider.Core; using Microsoft.SqlTools.ResourceProvider.Core.Authentication; using Microsoft.SqlTools.ResourceProvider.Core.Contracts; namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl { /// /// Implementation for using VS services /// Contains information about an Azure account /// public class AzureUserAccount : IAzureUserAccount { private string uniqueId; /// /// Default constructor to initializes user session /// public AzureUserAccount() { } /// /// Default constructor to initializes user session /// public AzureUserAccount(IAzureUserAccount azureUserAccount) { CopyFrom(azureUserAccount); } private void CopyFrom(IAzureUserAccount azureUserAccount) { this.DisplayInfo = new AzureUserAccountDisplayInfo(azureUserAccount.DisplayInfo); this.NeedsReauthentication = azureUserAccount.NeedsReauthentication; this.TenantId = azureUserAccount.TenantId; this.AllTenants = azureUserAccount.AllTenants; this.UniqueId = azureUserAccount.UniqueId; this.UnderlyingAccount = azureUserAccount.UnderlyingAccount; AzureUserAccount account = azureUserAccount as AzureUserAccount; } /// /// Returns true if given user account equals this class /// public bool Equals(IAzureUserAccount other) { return other != null && CommonUtil.SameString(other.UniqueId, UniqueId) && CommonUtil.SameString(other.TenantId, TenantId); // TODO probably should check the AllTenants field } /// /// Unique Id /// public string UniqueId { get { return uniqueId == null ? string.Empty : uniqueId; } set { this.uniqueId = value; } } /// /// Returns true if user needs reauthentication /// public bool NeedsReauthentication { get; set; } /// /// User display info /// public IAzureUserAccountDisplayInfo DisplayInfo { get; set; } /// /// Tenant Id /// public string TenantId { get; set; } public IList AllTenants { get; set; } public Account UnderlyingAccount { get; set; } } }