public NamedPipeConnectionPool(IPipeTransportFactorySettings settings) : base(settings, TimeSpan.MaxValue) { this.pipeNameCache = new PipeNameCache(); this.transportFactorySettings = settings; }
static AppContainerInfo GetAppContainerInfo(IPipeTransportFactorySettings transportFactorySettings) { if (AppContainerInfo.IsAppContainerSupported && transportFactorySettings != null && transportFactorySettings.PipeSettings != null) { ApplicationContainerSettings appSettings = transportFactorySettings.PipeSettings.ApplicationContainerSettings; if (appSettings != null && appSettings.TargetingAppContainer) { return AppContainerInfo.CreateAppContainerInfo(appSettings.PackageFullName, appSettings.SessionId); } } return null; }
internal static string GetPipeName(Uri uri, IPipeTransportFactorySettings transportFactorySettings) { AppContainerInfo appInfo = GetAppContainerInfo(transportFactorySettings); // for wildcard hostName support, we first try and connect to the StrongWildcard, // then the Exact HostName, and lastly the WeakWildcard string[] hostChoices = new string[] { "+", uri.Host, "*" }; bool[] globalChoices = new bool[] { true, false }; string matchPath = String.Empty; string matchPipeName = null; for (int i = 0; i < hostChoices.Length; i++) { for (int iGlobal = 0; iGlobal < globalChoices.Length; iGlobal++) { if (appInfo != null && globalChoices[iGlobal]) { // Don't look at shared memory to acces pipes // that are created in the local NamedObjectPath continue; } // walk up the path hierarchy, looking for match string path = PipeUri.GetPath(uri); while (path.Length > 0) { string sharedMemoryName = PipeUri.BuildSharedMemoryName(hostChoices[i], path, globalChoices[iGlobal], appInfo); try { PipeSharedMemory sharedMemory = PipeSharedMemory.Open(sharedMemoryName, uri); if (sharedMemory != null) { try { string pipeName = sharedMemory.GetPipeName(appInfo); if (pipeName != null) { // Found a matching pipe name. // If the best match app setting is enabled, save the match if it is the best so far and continue. // Otherwise, just return the first match we find. if (ServiceModelAppSettings.UseBestMatchNamedPipeUri) { if (path.Length > matchPath.Length) { matchPath = path; matchPipeName = pipeName; } } else { return pipeName; } } } finally { sharedMemory.Dispose(); } } } catch (AddressAccessDeniedException exception) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new EndpointNotFoundException(SR.GetString( SR.EndpointNotFound, uri.AbsoluteUri), exception)); } path = PipeUri.GetParentPath(path); } } } if (string.IsNullOrEmpty(matchPipeName)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new EndpointNotFoundException(SR.GetString(SR.EndpointNotFound, uri.AbsoluteUri), new PipeException(SR.GetString(SR.PipeEndpointNotFound, uri.AbsoluteUri)))); } return matchPipeName; }
public PipeConnectionInitiator(int bufferSize, IPipeTransportFactorySettings pipeSettings) { this.bufferSize = bufferSize; this.pipeSettings = pipeSettings; }
internal static string GetPipeName(Uri uri, IPipeTransportFactorySettings transportFactorySettings) { AppContainerInfo appInfo = GetAppContainerInfo(transportFactorySettings); // for wildcard hostName support, we first try and connect to the StrongWildcard, // then the Exact HostName, and lastly the WeakWildcard string[] hostChoices = new string[] { "+", uri.Host, "*" }; bool[] globalChoices = new bool[] { true, false }; for (int i = 0; i < hostChoices.Length; i++) { for (int iGlobal = 0; iGlobal < globalChoices.Length; iGlobal++) { if (appInfo != null && globalChoices[iGlobal]) { // Don't look at shared memory to acces pipes // that are created in the local NamedObjectPath continue; } // walk up the path hierarchy, looking for first match string path = PipeUri.GetPath(uri); while (path.Length > 0) { string sharedMemoryName = PipeUri.BuildSharedMemoryName(hostChoices[i], path, globalChoices[iGlobal], appInfo); try { PipeSharedMemory sharedMemory = PipeSharedMemory.Open(sharedMemoryName, uri); if (sharedMemory != null) { try { string pipeName = sharedMemory.GetPipeName(appInfo); if (pipeName != null) { return pipeName; } } finally { sharedMemory.Dispose(); } } } catch (AddressAccessDeniedException exception) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new EndpointNotFoundException(SR.GetString( SR.EndpointNotFound, uri.AbsoluteUri), exception)); } path = PipeUri.GetParentPath(path); } } } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new EndpointNotFoundException(SR.GetString(SR.EndpointNotFound, uri.AbsoluteUri), new PipeException(SR.GetString(SR.PipeEndpointNotFound, uri.AbsoluteUri)))); }