public bool Start() { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Start"); bool result = false; try { if (_host == null) { lock (_lock) { if (_host == null) { // Host string hostName = Dns.GetHostName(); // Add the base address Type serviceType = typeof(ConfigStoreService); Uri pipeUri = new Uri(ConfigStoreManager.GetPipeName(Process.GetCurrentProcess().Id)); Log.Info(PROC, pipeUri.AbsoluteUri); // default servuce if (true) { _host = new WcfServiceHost(serviceType, null, new Uri[] { pipeUri }); Type[] interfaces = serviceType.GetInterfaces(); string serviceContractAttrString = typeof(ServiceContractAttribute).ToString(); if (interfaces != null) { foreach (Type iface in interfaces) { ServiceContractAttribute serviceContractAttr = (from c in iface.GetCustomAttributes(false) where c.ToString() == serviceContractAttrString select c).FirstOrDefault() as ServiceContractAttribute; if (serviceContractAttr != null) { // named pipe _host.AddServiceEndpoint(iface, CreateNamedPipeBinding(), pipeUri); } } } } // Mex endpoings _host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexNamedPipeBinding(), "mex"); Log.Info(PROC, pipeUri.AbsoluteUri + "/mex"); } } } // default service host try { if (_host != null && _host.State == CommunicationState.Created) { _host.Open(); result = true; } } catch (Exception ex) { Log.Exception(PROC, ex); } } catch (Exception ex) { Log.Exception(PROC, ex); } return(result); }
public ConfigStoreServiceProxy(int processId) : base(ConfigStoreServiceHostFactory.CreateNamedPipeBinding(), ConfigStoreManager.GetPipeName(processId)) { }