// -----------------------------------------------------------------------
+using System;
+using System.ServiceModel.Description;
using Caliburn.Micro;
using System.ServiceModel;
using System.ComponentModel.Composition;
[Import]
public PithosMonitor Monitor { get; set; }
+ [Import]
+ public IEventAggregator Events { get; set; }
+
public StatusService()
{
IoC.BuildUp(this);
- }
-
- private IEventAggregator _events;
-
- [ImportingConstructor]
- public StatusService(IStatusChecker checker,IEventAggregator events)
- {
- Checker = checker;
- _events = events;
- }
-
+ }
public FileOverlayStatus GetStatus(string filePath)
{
public void ShowProperties(string fileName)
{
- _events.Publish(new ShowFilePropertiesEvent(fileName));
+ Events.Publish(new ShowFilePropertiesEvent(fileName));
+ }
+
+ public static ServiceHost Start()
+ {
+ // Create a ServiceHost for the CalculatorService type and provide the base address.
+ var baseAddress = new Uri("net.pipe://localhost/pithos");
+ var service = new ServiceHost(typeof(StatusService), baseAddress);
+
+ var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
+
+ service.AddServiceEndpoint(typeof(IStatusService), binding, "net.pipe://localhost/pithos/statuscache");
+ service.AddServiceEndpoint(typeof(ISettingsService), binding, "net.pipe://localhost/pithos/settings");
+ service.AddServiceEndpoint(typeof(ICommandsService), binding, "net.pipe://localhost/pithos/commands");
+
+
+ //// Add a mex endpoint
+ var smb = new ServiceMetadataBehavior
+ {
+ HttpGetEnabled = true,
+ HttpGetUrl = new Uri("http://localhost:30000/pithos/mex")
+ };
+ service.Description.Behaviors.Add(smb);
+
+
+ service.Open();
+ return service;
+ }
+
+ public static void Stop(ServiceHost statusService)
+ {
+ if (statusService == null)
+ return;
+
+ if (statusService.State == CommunicationState.Faulted)
+ statusService.Abort();
+ else if (statusService.State != CommunicationState.Closed)
+ statusService.Close();
+
}
}
}