Пример #1
0
        void ExecEnvDelete()
        {
            if (!(EnvList.SelectedItem is Environment env))
            {
                return;
            }

            if (Configuration.Instance.LocalSettings.ConfirmDelete)
            {
                if (MessageBoxResult.Yes != MessageBox.Show(
                        $"Are you sure you want to delete environment '{env.Name}'?",
                        Strings.APP_NAME,
                        MessageBoxButton.YesNo,
                        MessageBoxImage.Warning
                        ))
                {
                    return;
                }
            }

            var idx = EnvList.SelectedIndex;

            env.Delete();
            Environments.Remove(env);
            EnvList.SelectedIndex = Math.Min(idx, Environments.Count - 1);;
        }
        /// <summary>
        /// Writes profile to a specified path.
        /// </summary>
        /// <param name="path"></param>
        public void Save(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            // 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 (AzureSession.DataStore.FileExists(path))
            {
                diskContents = AzureSession.DataStore.ReadFileAsText(path);
            }

            if (diskContents != contents)
            {
                AzureSession.DataStore.WriteFile(path, contents);
            }
        }
Пример #3
0
        public void RemoveEnvironment(ApplicationEnvironment environment)
        {
            Guard.IsNotNull(Environments, "Unload environments");
            Guard.IsTrue(Environments.Any(x => x.Id == environment.Id), "Invalid environment");
            Guard.IsFalse(environment.IsDefault, "You can't delete the default environment");

            Environments.Remove(environment);
        }
Пример #4
0
        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);
            }
        }
        /// <summary>
        /// Writes profile to a specified path.
        /// </summary>
        /// <param name="path">File path on disk to save profile to</param>
        public void Save(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            // Removing predefined environments
            foreach (string env in AzureEnvironment.PublicEnvironments.Keys)
            {
                Environments.Remove(env);
            }

            try
            {
                string contents     = ToString();
                string diskContents = string.Empty;
                if (AzureSession.DataStore.FileExists(path))
                {
                    diskContents = AzureSession.DataStore.ReadFileAsText(path);
                }

                if (diskContents != contents)
                {
                    AzureSession.DataStore.WriteFile(path, contents);
                }
            }
            finally
            {
                // Adding back predefined environments
                foreach (AzureEnvironment env in AzureEnvironment.PublicEnvironments.Values)
                {
                    Environments[env.Name] = env;
                }
            }
        }
Пример #6
0
 private bool RemoveEnvironment(Environment env)
 {
     return(Environments.Remove(env));
 }