Esempio n. 1
0
        // This is virtual so that PeerChannelListener and MsmqChannelListener can override it.
        // Will be called under "lock (this.TransportManagerTable)" from TransportManagerContainer.Open
        internal virtual IList <TransportManager> SelectTransportManagers()
        {
            IList <TransportManager> foundTransportManagers = null;

            // Look up an existing transport manager registration.
            ITransportManagerRegistration registration;

            if (!TryGetTransportManagerRegistration(out registration))
            {
                // Don't create TransportManagerRegistration in hosted case.
                if (HostedVirtualPath == null)
                {
                    // Create a new registration at the default point in the URI hierarchy.
                    registration = CreateTransportManagerRegistration();
                    TransportManagerTable.RegisterUri(registration.ListenUri, hostNameComparisonMode, registration);
                }
            }

            // Use the registration to select/create a set of compatible transport managers.
            if (registration != null)
            {
                foundTransportManagers = registration.Select(this);
                if (foundTransportManagers == null)
                {
                    // Don't create TransportManagerRegistration in hosted case.
                    if (HostedVirtualPath == null)
                    {
                        // Create a new registration one segment down from the existing incompatible registration.
                        Uri nextUri = AddSegment(registration.ListenUri, Uri);
                        if (nextUri != null)
                        {
                            registration = CreateTransportManagerRegistration(nextUri);
                            TransportManagerTable.RegisterUri(nextUri, hostNameComparisonMode, registration);
                            foundTransportManagers = registration.Select(this);
                        }
                    }
                }
            }

            if (foundTransportManagers == null)
            {
                ThrowTransportManagersNotFound();
            }

            return(foundTransportManagers);
        }
Esempio n. 2
0
 protected virtual bool TryGetTransportManagerRegistration(HostNameComparisonMode hostNameComparisonMode,
                                                           out ITransportManagerRegistration registration)
 {
     return(TransportManagerTable.TryLookupUri(Uri, hostNameComparisonMode, out registration));
 }