github.com/ijc/docker-app@v0.6.1-0.20181012090447-c7ca8bc483fb/integrations/visualstudio/dockerappvsix/AppPackageSettings.cs (about) 1 using EnvDTE; 2 using System; 3 using System.Collections.Generic; 4 using System.ComponentModel; 5 using System.Linq; 6 using System.Runtime.CompilerServices; 7 using System.Text; 8 using System.Threading.Tasks; 9 10 namespace dockerappvsix 11 { 12 public class AppPackageSettings : INotifyPropertyChanged 13 { 14 private bool _isSwarm; 15 private bool _isKubernetes; 16 private string _kubeConfig; 17 private string _namespace; 18 private string _stackName; 19 private string _settings; 20 21 public bool IsSwarm 22 { 23 get => _isSwarm; 24 set 25 { 26 _isSwarm = value; 27 OnPropertyChanged(); 28 } 29 } 30 public bool IsKubernetes 31 { 32 get => _isKubernetes; 33 set 34 { 35 _isKubernetes = value; 36 OnPropertyChanged(); 37 } 38 } 39 public string KubeConfig 40 { 41 get => _kubeConfig; 42 set 43 { 44 _kubeConfig = value; 45 OnPropertyChanged(); 46 } 47 } 48 public string Namespace 49 { 50 get => _namespace; 51 set 52 { 53 _namespace = value; 54 OnPropertyChanged(); 55 } 56 } 57 public string StackName 58 { 59 get => _stackName; 60 set 61 { 62 _stackName = value; 63 OnPropertyChanged(); 64 } 65 } 66 public string Settings 67 { 68 get => _settings; 69 set 70 { 71 _settings = value; 72 OnPropertyChanged(); 73 } 74 } 75 76 public void LoadFromSolution(Globals g) 77 { 78 var orchestrator = g.GetOrNull<string>("dockerapp_orchestrator"); 79 IsSwarm = orchestrator != "kubernetes"; 80 IsKubernetes = orchestrator == "kubernetes"; 81 KubeConfig = g.GetOrNull<string>("dockerapp_kubeconfig"); 82 Namespace = g.GetOrNull<string>("dockerapp_namespace"); 83 StackName = g.GetOrNull<string>("dockerapp_stackname"); 84 Settings = g.GetOrNull<string>("dockerapp_settings"); 85 } 86 87 public void Save(Globals g) 88 { 89 var orchestrator = IsKubernetes ? "kubernetes" : "swarm"; 90 g["dockerapp_orchestrator"] = orchestrator; 91 g.VariablePersists["dockerapp_orchestrator"] = true; 92 g["dockerapp_kubeconfig"] = KubeConfig; 93 g.VariablePersists["dockerapp_kubeconfig"] = true; 94 g["dockerapp_namespace"] = Namespace; 95 g.VariablePersists["dockerapp_namespace"] = true; 96 g["dockerapp_stackname"] = StackName; 97 g.VariablePersists["dockerapp_stackname"] = true; 98 g["dockerapp_settings"] = Settings; 99 g.VariablePersists["dockerapp_settings"] = true; 100 } 101 102 private void OnPropertyChanged([CallerMemberName]string name = null) 103 { 104 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); 105 } 106 public event PropertyChangedEventHandler PropertyChanged; 107 } 108 }