private void ResetData()
 {
     ProfileData = new ProfileData();
     ProfileData.DefaultEnvironmentName = EnvironmentName.AzureCloud;
     ProfileData.Environments = new List<AzureEnvironmentData>();
     ProfileData.Subscriptions = new List<AzureSubscriptionData>();
 }
 public void Save(ProfileData profile)
 {
     ProfileData.DefaultEnvironmentName = profile.DefaultEnvironmentName;
     ProfileData.Environments = new List<AzureEnvironmentData>();
     ProfileData.Subscriptions = new List<AzureSubscriptionData>();
     foreach (var env in profile.Environments)
     {
         ((List<AzureEnvironmentData>)ProfileData.Environments).Add(env);
     }
     foreach (var sub in profile.Subscriptions)
     {
         ((List<AzureSubscriptionData>)ProfileData.Subscriptions).Add(sub);
     }
 }
        /// <summary>
        /// Save the given profile data to the store.
        /// </summary>
        /// <param name="profile">Data to store.</param>
        public void Save(ProfileData profile)
        {
            string tempFilePath;

            var settings = new XmlWriterSettings { Indent = true, CloseOutput = true };

            using (var w = XmlWriter.Create(CreateTempFile(out tempFilePath), settings))
            {
                var serializer = new DataContractSerializer(typeof(ProfileData));
                serializer.WriteObject(w, profile);
            }

            File.Replace(tempFilePath, FullProfilePath, null);
        }
 private void LoadSubscriptionData(ProfileData data)
 {
     if (data.Subscriptions != null)
     {
         foreach (var s in data.Subscriptions)
         {
             var newSub = s.ToAzureSubscription();
             AddSubscriptionInternal(newSub);
         }
     }
 }
 private void SetSubscriptionData(ProfileData data)
 {
     data.Subscriptions = Subscriptions.Select(s => new AzureSubscriptionData(s)).ToList();
 }
 private void LoadEnvironmentData(ProfileData data)
 {
     if (data.Environments != null)
     {
         foreach (var e in data.Environments.Select(e => e.ToAzureEnvironment()))
         {
             environments[e.Name] = e;
             MigrateExistingEnvironments(e.Name);
         }
         if (environments.ContainsKey(data.DefaultEnvironmentName))
         {
             currentEnvironment = environments[data.DefaultEnvironmentName];
         }
     }
 }
 private void SetEnvironmentData(ProfileData data)
 {
     data.DefaultEnvironmentName = CurrentEnvironment.Name;
     data.Environments = Environments.Values
         .Where(e => !IsPublicEnvironment(e.Name))
         .Select(e => new AzureEnvironmentData(e)).ToList();
 }
 public void Save()
 {
     var profileData = new ProfileData();
     SetEnvironmentData(profileData);
     SetSubscriptionData(profileData);
     profileStore.Save(profileData);
 }
 public void Save(ProfileData profile)
 {
     EnsureNewStore();
     newStore.Save(profile);
 }
 public void Save(ProfileData profile)
 {
     EnsureNewStore();
     newStore.Save(profile);
 }
 public void Save(ProfileData profile)
 {
     // This will never be used, all writes go to the new format
     throw new InvalidOperationException();
 }
Exemple #12
0
 private void SetSubscriptionData(ProfileData data)
 {
     data.Subscriptions = Subscriptions.Select(s => new AzureSubscriptionData(s)).ToList();
 }