public void Save() { ProtectedSettings toSave = new ProtectedSettings(Settings); toSave.Proxy = new ProxySetting(App.Kernel.Get <ProxyManager>().Settings); IProfileManager ProfileManager = App.Kernel.Get <IProfileManager>(); if (ProfileManager.DefaultProfile != null) { toSave.DefaultProfile = ProfileManager.DefaultProfile.Id; } if (ProfileManager.Profiles != null) { LoginManager loginManager = App.Kernel.Get <LoginManager>(); foreach (Profile profile in ProfileManager.Profiles) { ProtectedProfile protectedProfile = new ProtectedProfile(profile); LoginData login = loginManager.GetCredentials(profile); if (login != null) { protectedProfile.Login = new LoginData(login); } toSave.Profiles.Add(protectedProfile); } } new FileIOPermission(FileIOPermissionAccess.Write, SettingsFile).Assert(); XmlSerializer writer = new XmlSerializer(typeof(ProtectedSettings)); using (var file = new StreamWriter(SettingsFile)) { writer.Serialize(file, toSave); } }
private void ReloadProfiles() { ProfileManager.RevertChanges(); Credentials.Clear(); LoginManager loginManager = App.Kernel.Get <LoginManager>(); foreach (Profile p in ProfileManager.PendingProfiles) { if (p.Id == ProfileManager.CurrentProfile.Id) { ProfileList.SelectedItem = p; } LoginData data = loginManager.GetCredentials(p); Credentials.Add(p, new LoginData(data)); } OnProfileSelectionChanged(this, null); }