private static void Serialize(PackagePreferences toSerialize)
        {
            var preferencesPath = MakePreferencesPath();

            Directory.CreateDirectory(Path.GetDirectoryName(preferencesPath) ?? throw new Exception("unable to locate preferences"));
            File.WriteAllText(preferencesPath, JsonUtility.ToJson(toSerialize));
        }
 private void DrawSlackSettings()
 {
     EditorGUILayout.LabelField("Slack Settings");
     EditorGUILayout.BeginVertical(GUI.skin.box);
     preferences.slackWebhook = EditorGUILayout.TextField("Slack Webhook", preferences.slackWebhook);
     preferences.postToSlack  = EditorGUILayout.Toggle("Post To Slack", preferences.postToSlack);
     preferences = preferencesManager.Update(preferences);
     EditorGUILayout.EndVertical();
 }
        public PackagePreferences Update(PackagePreferences updated)
        {
            if (preferences.Equals(updated))
            {
                return(updated);
            }

            preferences = updated;
            Serialize(preferences);
            UpdateShell();
            return((PackagePreferences)preferences.Clone());
        }
        private void InitState()
        {
            if (butler != null)
            {
                return;
            }

            var shell = new ShellWrapper();

            butler             = new Butler(shell);
            preferencesManager = new PackagePreferencesManager(shell);
            preferences        = preferencesManager.ClonePreferences();
        }
 public PackagePreferencesManager(ShellWrapper shell)
 {
     this.shell  = shell;
     preferences = Deserialize();
     UpdateShell();
 }