// ----------------------------------------------------------------------- // // TODO: Update copyright text. // // ----------------------------------------------------------------------- using System.Collections; using System.IO; using System.IO.IsolatedStorage; using System.Runtime.Serialization; namespace Pithos.Client.WPF { using System; using System.Collections.Generic; using System.Linq; using System.Text; /// /// TODO: Update summary. /// public class ShellExtensionController { #region Shell Extensions public void UnregisterExtensions() { using (var installer = new ProjectInstaller()) { IDictionary state = LoadState(); installer.Uninstall(state); } } public void RegisterExtensions() { using (var installer = new ProjectInstaller()) { IDictionary state = new Dictionary(); installer.Install(state); SaveState(state); } } private static void SaveState(IDictionary state) { using (var store = IsolatedStorageFile.GetUserStoreForAssembly()) using (var file = store.CreateFile("PithosManualInstallFile")) { var serializer = new NetDataContractSerializer(); serializer.Serialize(file, state); } } private static IDictionary LoadState() { using (var store = IsolatedStorageFile.GetUserStoreForAssembly()) { if (!store.FileExists("PithosManualInstallFile")) return new Dictionary(); using (var file = store.OpenFile("PithosManualInstallFile", FileMode.Open)) { var serializer = new NetDataContractSerializer(); var state = serializer.Deserialize(file); return (IDictionary)state; } } } #endregion } }