Revision 42800be8 trunk/Pithos.Client.WPF/Services/StatusService.cs
b/trunk/Pithos.Client.WPF/Services/StatusService.cs | ||
---|---|---|
5 | 5 |
// ----------------------------------------------------------------------- |
6 | 6 |
|
7 | 7 |
|
8 |
using System; |
|
9 |
using System.ServiceModel.Description; |
|
8 | 10 |
using Caliburn.Micro; |
9 | 11 |
using System.ServiceModel; |
10 | 12 |
using System.ComponentModel.Composition; |
... | ... | |
29 | 31 |
[Import] |
30 | 32 |
public PithosMonitor Monitor { get; set; } |
31 | 33 |
|
34 |
[Import] |
|
35 |
public IEventAggregator Events { get; set; } |
|
36 |
|
|
32 | 37 |
public StatusService() |
33 | 38 |
{ |
34 | 39 |
IoC.BuildUp(this); |
35 |
} |
|
36 |
|
|
37 |
private IEventAggregator _events; |
|
38 |
|
|
39 |
[ImportingConstructor] |
|
40 |
public StatusService(IStatusChecker checker,IEventAggregator events) |
|
41 |
{ |
|
42 |
Checker = checker; |
|
43 |
_events = events; |
|
44 |
} |
|
45 |
|
|
40 |
} |
|
46 | 41 |
|
47 | 42 |
public FileOverlayStatus GetStatus(string filePath) |
48 | 43 |
{ |
... | ... | |
62 | 57 |
|
63 | 58 |
public void ShowProperties(string fileName) |
64 | 59 |
{ |
65 |
_events.Publish(new ShowFilePropertiesEvent(fileName)); |
|
60 |
Events.Publish(new ShowFilePropertiesEvent(fileName)); |
|
61 |
} |
|
62 |
|
|
63 |
public static ServiceHost Start() |
|
64 |
{ |
|
65 |
// Create a ServiceHost for the CalculatorService type and provide the base address. |
|
66 |
var baseAddress = new Uri("net.pipe://localhost/pithos"); |
|
67 |
var service = new ServiceHost(typeof(StatusService), baseAddress); |
|
68 |
|
|
69 |
var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); |
|
70 |
|
|
71 |
service.AddServiceEndpoint(typeof(IStatusService), binding, "net.pipe://localhost/pithos/statuscache"); |
|
72 |
service.AddServiceEndpoint(typeof(ISettingsService), binding, "net.pipe://localhost/pithos/settings"); |
|
73 |
service.AddServiceEndpoint(typeof(ICommandsService), binding, "net.pipe://localhost/pithos/commands"); |
|
74 |
|
|
75 |
|
|
76 |
//// Add a mex endpoint |
|
77 |
var smb = new ServiceMetadataBehavior |
|
78 |
{ |
|
79 |
HttpGetEnabled = true, |
|
80 |
HttpGetUrl = new Uri("http://localhost:30000/pithos/mex") |
|
81 |
}; |
|
82 |
service.Description.Behaviors.Add(smb); |
|
83 |
|
|
84 |
|
|
85 |
service.Open(); |
|
86 |
return service; |
|
87 |
} |
|
88 |
|
|
89 |
public static void Stop(ServiceHost statusService) |
|
90 |
{ |
|
91 |
if (statusService == null) |
|
92 |
return; |
|
93 |
|
|
94 |
if (statusService.State == CommunicationState.Faulted) |
|
95 |
statusService.Abort(); |
|
96 |
else if (statusService.State != CommunicationState.Closed) |
|
97 |
statusService.Close(); |
|
98 |
|
|
66 | 99 |
} |
67 | 100 |
} |
68 | 101 |
} |
Also available in: Unified diff