Statistics
| Branch: | Revision:

root / trunk / Pithos.ShellExtensions / PithosHost.cs @ 42800be8

History | View | Annotate | Download (2.3 kB)

1
// -----------------------------------------------------------------------
2
// <copyright file="PithosHost.cs" company="Microsoft">
3
// TODO: Update copyright text.
4
// </copyright>
5
// -----------------------------------------------------------------------
6

    
7
using System.Diagnostics;
8
using System.IO;
9
using System.ServiceModel;
10
using Microsoft.Win32;
11
using Pithos.ShellExtensions.PithosService;
12

    
13
namespace Pithos.ShellExtensions
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 static class PithosHost
24
    {
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

    
38
        public static StatusServiceClient GetStatusClient()
39
        {
40
            EnsureHost();
41

    
42
            var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
43
            var remoteAddress = new EndpointAddress("net.pipe://localhost/pithos/statuscache");
44

    
45
            return new StatusServiceClient(binding, remoteAddress);
46
        }
47

    
48
        public static SettingsServiceClient GetSettingsClient()
49
        {
50
            EnsureHost();
51

    
52
            var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
53
            var remoteAddress = new EndpointAddress("net.pipe://localhost/pithos/settings");
54

    
55
            return new SettingsServiceClient(binding, remoteAddress);
56
        }
57

    
58
        public static CommandsServiceClient GetCommandsClient()
59
        {
60
            EnsureHost();
61

    
62
            var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
63
            var remoteAddress = new EndpointAddress("net.pipe://localhost/pithos/commands");
64

    
65
            return new CommandsServiceClient(binding, remoteAddress);
66
        }
67

    
68
        
69
    }
70
}