Пример #1
0
        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;
            }
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
        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
            }
        }
Пример #4
0
        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
            }
        }