internal static string GetPipeName(Uri uri) { string[] strArray = new string[] { "+", uri.Host, "*" }; bool[] flagArray2 = new bool[2]; flagArray2[0] = true; bool[] flagArray = flagArray2; for (int i = 0; i < strArray.Length; i++) { for (int j = 0; j < flagArray.Length; j++) { for (string str = PipeUri.GetPath(uri); str.Length > 0; str = PipeUri.GetParentPath(str)) { string sharedMemoryName = PipeUri.BuildSharedMemoryName(strArray[i], str, flagArray[j]); try { PipeSharedMemory memory = PipeSharedMemory.Open(sharedMemoryName, uri); if (memory != null) { try { string pipeName = memory.PipeName; if (pipeName != null) { return(pipeName); } } finally { memory.Dispose(); } } } catch (AddressAccessDeniedException exception) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new EndpointNotFoundException(System.ServiceModel.SR.GetString("EndpointNotFound", new object[] { uri.AbsoluteUri }), exception)); } } } } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new EndpointNotFoundException(System.ServiceModel.SR.GetString("EndpointNotFound", new object[] { uri.AbsoluteUri }), new PipeException(System.ServiceModel.SR.GetString("PipeEndpointNotFound", new object[] { uri.AbsoluteUri })))); }
public void Listen() { lock (this.ThisLock) { if (!this.isListening) { string sharedMemoryName = PipeUri.BuildSharedMemoryName(this.pipeUri, this.hostNameComparisonMode, true); if (!PipeSharedMemory.TryCreate(this.allowedSids, this.pipeUri, sharedMemoryName, out this.sharedMemory)) { PipeSharedMemory result = null; Uri uri = new Uri(this.pipeUri, Guid.NewGuid().ToString()); string str2 = PipeUri.BuildSharedMemoryName(uri, this.hostNameComparisonMode, true); if (PipeSharedMemory.TryCreate(this.allowedSids, uri, str2, out result)) { result.Dispose(); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(PipeSharedMemory.CreatePipeNameInUseException(5, this.pipeUri)); } sharedMemoryName = PipeUri.BuildSharedMemoryName(this.pipeUri, this.hostNameComparisonMode, false); this.sharedMemory = PipeSharedMemory.Create(this.allowedSids, this.pipeUri, sharedMemoryName); } this.isListening = true; } } }