Revision 3ddbb7b8 trunk/Pithos.ShellExtensions/PithosHost.cs
b/trunk/Pithos.ShellExtensions/PithosHost.cs | ||
---|---|---|
4 | 4 |
// </copyright> |
5 | 5 |
// ----------------------------------------------------------------------- |
6 | 6 |
|
7 |
using System.Diagnostics; |
|
8 |
using System.IO; |
|
9 | 7 |
using System.ServiceModel; |
10 |
using Microsoft.Win32; |
|
11 | 8 |
using Pithos.ShellExtensions.PithosService; |
12 | 9 |
|
13 | 10 |
namespace Pithos.ShellExtensions |
14 | 11 |
{ |
15 |
using System; |
|
16 |
using System.Collections.Generic; |
|
17 |
using System.Linq; |
|
18 |
using System.Text; |
|
19 |
|
|
20 | 12 |
/// <summary> |
21 |
/// TODO: Update summary.
|
|
13 |
/// Returns the status service clients
|
|
22 | 14 |
/// </summary> |
23 | 15 |
public static class PithosHost |
24 | 16 |
{ |
25 |
public static void EnsureHost() |
|
26 |
{ |
|
27 |
return; |
|
28 |
if (Process.GetProcessesByName("Pithos.Client.WPF").Length == 0 && |
|
29 |
Process.GetProcessesByName("Pithos.Client.WPF.vshost").Length == 0) |
|
30 |
{ |
|
31 |
var fileName = (string)Registry.LocalMachine.GetValue(@"Software\Pithos\AppPath"); |
|
32 |
var workingDirectory = Path.GetDirectoryName(fileName); |
|
33 |
var info = new ProcessStartInfo {FileName = fileName, WorkingDirectory = workingDirectory}; |
|
34 |
Process.Start(info); |
|
35 |
} |
|
36 |
} |
|
37 |
|
|
17 |
/// <summary> |
|
18 |
/// Provides a client for retrieving file status from the Pithos App |
|
19 |
/// </summary> |
|
20 |
/// <returns></returns> |
|
38 | 21 |
public static StatusServiceClient GetStatusClient() |
39 | 22 |
{ |
40 |
EnsureHost(); |
|
41 |
|
|
42 | 23 |
var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); |
43 | 24 |
var remoteAddress = new EndpointAddress("net.pipe://localhost/pithos/statuscache"); |
44 | 25 |
|
45 | 26 |
return new StatusServiceClient(binding, remoteAddress); |
46 | 27 |
} |
47 | 28 |
|
29 |
/// <summary> |
|
30 |
/// Provides a client for retrieving settings from the Pithos App |
|
31 |
/// </summary> |
|
32 |
/// <returns></returns> |
|
48 | 33 |
public static SettingsServiceClient GetSettingsClient() |
49 | 34 |
{ |
50 |
EnsureHost(); |
|
51 |
|
|
52 | 35 |
var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); |
53 | 36 |
var remoteAddress = new EndpointAddress("net.pipe://localhost/pithos/settings"); |
54 | 37 |
|
55 | 38 |
return new SettingsServiceClient(binding, remoteAddress); |
56 | 39 |
} |
57 | 40 |
|
41 |
|
|
42 |
/// <summary> |
|
43 |
/// Provides a client for sending commands to the Pithos Client |
|
44 |
/// </summary> |
|
45 |
/// <returns></returns> |
|
58 | 46 |
public static CommandsServiceClient GetCommandsClient() |
59 | 47 |
{ |
60 |
EnsureHost(); |
|
61 |
|
|
62 | 48 |
var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); |
63 | 49 |
var remoteAddress = new EndpointAddress("net.pipe://localhost/pithos/commands"); |
64 | 50 |
|
Also available in: Unified diff