private void Load() { Environments = new Dictionary<string, AzureEnvironment>(StringComparer.InvariantCultureIgnoreCase); Subscriptions = new Dictionary<Guid, AzureSubscription>(); Accounts = new Dictionary<string, AzureAccount>(StringComparer.InvariantCultureIgnoreCase); if (!store.DirectoryExists(AzurePowerShell.ProfileDirectory)) { store.CreateDirectory(AzurePowerShell.ProfileDirectory); } if (store.FileExists(profilePath)) { string contents = store.ReadFileAsText(profilePath); IProfileSerializer serializer; if (ParserHelper.IsXml(contents)) { serializer = new XmlProfileSerializer(); serializer.Deserialize(contents, this); } else if (ParserHelper.IsJson(contents)) { serializer = new JsonProfileSerializer(); serializer.Deserialize(contents, this); } } // Adding predefined environments foreach (AzureEnvironment env in AzureEnvironment.PublicEnvironments.Values) { Environments[env.Name] = env; } }
private void Load() { Environments = new Dictionary <string, AzureEnvironment>(StringComparer.InvariantCultureIgnoreCase); Subscriptions = new Dictionary <Guid, AzureSubscription>(); Accounts = new Dictionary <string, AzureAccount>(StringComparer.InvariantCultureIgnoreCase); if (!store.DirectoryExists(AzurePowerShell.ProfileDirectory)) { store.CreateDirectory(AzurePowerShell.ProfileDirectory); } if (store.FileExists(profilePath)) { string contents = store.ReadFileAsText(profilePath); IProfileSerializer serializer; if (ParserHelper.IsXml(contents)) { serializer = new XmlProfileSerializer(); serializer.Deserialize(contents, this); } else if (ParserHelper.IsJson(contents)) { serializer = new JsonProfileSerializer(); serializer.Deserialize(contents, this); } } // Adding predefined environments foreach (AzureEnvironment env in AzureEnvironment.PublicEnvironments.Values) { Environments[env.Name] = env; } }
private void LoadProfile() { JsonProfileSerializer jsonSerializer = new JsonProfileSerializer(); XmlProfileSerializer xmlSerializer = new XmlProfileSerializer(); string xmlProfilePath = Path.Combine(DefaultProfilePath, xmlSerializer.ProfileFile); string jsonProfilePath = Path.Combine(DefaultProfilePath, jsonSerializer.ProfileFile); if (store.FileExists(xmlProfilePath)) { AzureProfile profile = xmlSerializer.Deserialize(store.ReadFile(xmlProfilePath)); Copy(profile); SaveProfile(); } else if (store.FileExists(jsonProfilePath)) { // Do JSON parsing } }
private void LoadProfile() { JsonProfileSerializer jsonSerializer = new JsonProfileSerializer(); XmlProfileSerializer xmlSerializer = new XmlProfileSerializer(); string xmlProfilePath = Path.Combine(DefaultProfilePath, xmlSerializer.ProfileFile); string jsonProfilePath = Path.Combine(DefaultProfilePath, jsonSerializer.ProfileFile); if (store.FileExists(xmlProfilePath)) { AzureProfile profile = xmlSerializer.Deserialize(store.ReadFile(xmlProfilePath)); Copy(profile); SaveProfile(); } else if (store.FileExists(jsonProfilePath)) { // Do JSON parsing } }
public void Save() { // Removing predefined environments foreach (string env in AzureEnvironment.PublicEnvironments.Keys) { Environments.Remove(env); } JsonProfileSerializer jsonSerializer = new JsonProfileSerializer(); string contents = jsonSerializer.Serialize(this); string diskContents = string.Empty; if (store.FileExists(profilePath)) { diskContents = store.ReadFileAsText(profilePath); } if (diskContents != contents) { store.WriteFile(profilePath, contents); } }
public void Save() { // Removing predefined environments foreach (string env in AzureEnvironment.PublicEnvironments.Keys) { Environments.Remove(env); } JsonProfileSerializer jsonSerializer = new JsonProfileSerializer(); string contents = jsonSerializer.Serialize(this); string diskContents = string.Empty; if (store.FileExists(profilePath)) { diskContents = store.ReadFileAsText(profilePath); } if (diskContents != contents) { store.WriteFile(profilePath, contents); } }