Added File/Container properties windows
[pithos-ms-client] / trunk / Pithos.Client.WPF / Services / StatusService.cs
index d91546c..eb2389b 100644 (file)
@@ -5,6 +5,8 @@
 // -----------------------------------------------------------------------
 
 
+using System;
+using System.ServiceModel.Description;
 using Caliburn.Micro;
 using System.ServiceModel;
 using System.ComponentModel.Composition;
@@ -29,20 +31,13 @@ namespace Pithos.Client.WPF.Services
         [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)
         {
@@ -62,7 +57,45 @@ namespace Pithos.Client.WPF.Services
 
         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();            
+
         }
     }
 }