示例#1
0
        /// <summary>
        /// Convert the older representation of accounts into the newer representation
        /// </summary>
        /// <param name="account">The legacy account to convert</param>
        /// <returns>An AzureAccount model with data copied from the legacy account</returns>
        public static IAzureAccount Convert(this LegacyAzureAccount account)
        {
            var result = new AzureAccount();

            result.Id   = account.Id;
            result.Type = ConvertAccountType(account.Type);

            foreach (var property in account.Properties)
            {
                result.SetProperty(property.Key, property.Value);
            }

            if (result.IsPropertySet(AzureAccount.Property.AccessToken))
            {
                result.Credential = result.GetAccessToken();
            }

            return(result);
        }