root / trunk / Pithos.Client.WPF / ShellExtensionController.cs @ da8e1a87
History | View | Annotate | Download (2.2 kB)
1 |
// ----------------------------------------------------------------------- |
---|---|
2 |
// <copyright file="ShellExtensionController.cs" company="Microsoft"> |
3 |
// TODO: Update copyright text. |
4 |
// </copyright> |
5 |
// ----------------------------------------------------------------------- |
6 |
|
7 |
using System.Collections; |
8 |
using System.IO; |
9 |
using System.IO.IsolatedStorage; |
10 |
using System.Runtime.Serialization; |
11 |
|
12 |
|
13 |
namespace Pithos.Client.WPF |
14 |
{ |
15 |
using System; |
16 |
using System.Collections.Generic; |
17 |
using System.Linq; |
18 |
using System.Text; |
19 |
|
20 |
/// <summary> |
21 |
/// TODO: Update summary. |
22 |
/// </summary> |
23 |
public class ShellExtensionController |
24 |
{ |
25 |
#region Shell Extensions |
26 |
public void UnregisterExtensions() |
27 |
{ |
28 |
using (var installer = new ProjectInstaller()) |
29 |
{ |
30 |
IDictionary state = LoadState(); |
31 |
installer.Uninstall(state); |
32 |
} |
33 |
} |
34 |
|
35 |
public void RegisterExtensions() |
36 |
{ |
37 |
using (var installer = new ProjectInstaller()) |
38 |
{ |
39 |
IDictionary state = new Dictionary<object, object>(); |
40 |
installer.Install(state); |
41 |
SaveState(state); |
42 |
|
43 |
} |
44 |
} |
45 |
|
46 |
private static void SaveState(IDictionary state) |
47 |
{ |
48 |
using (var store = IsolatedStorageFile.GetUserStoreForAssembly()) |
49 |
using (var file = store.CreateFile("PithosManualInstallFile")) |
50 |
{ |
51 |
var serializer = new NetDataContractSerializer(); |
52 |
serializer.Serialize(file, state); |
53 |
} |
54 |
} |
55 |
|
56 |
private static IDictionary LoadState() |
57 |
{ |
58 |
using (var store = IsolatedStorageFile.GetUserStoreForAssembly()) |
59 |
{ |
60 |
if (!store.FileExists("PithosManualInstallFile")) |
61 |
return new Dictionary<object, object>(); |
62 |
|
63 |
using (var file = store.OpenFile("PithosManualInstallFile", FileMode.Open)) |
64 |
{ |
65 |
var serializer = new NetDataContractSerializer(); |
66 |
var state = serializer.Deserialize(file); |
67 |
return (IDictionary)state; |
68 |
} |
69 |
} |
70 |
} |
71 |
|
72 |
#endregion |
73 |
} |
74 |
} |