private void ReadExtendedProtocol(MemoryStream mem, uint cbTmProtocolData)
 {
     Guid guid = SerializationUtils.ReadGuid(mem);
     if ((guid == PluggableProtocol10.ProtocolGuid) || (guid == PluggableProtocol11.ProtocolGuid))
     {
         this.protocolInfo = new ProtocolInformationReader(mem);
     }
     else
     {
         SerializationUtils.IncrementPosition(mem, (long) (cbTmProtocolData - 0x10));
     }
 }
        EndpointAddress CreateActivationEndpointAddress(ProtocolInformationReader protocol,
                                              string suffix,
                                              string spnIdentity,
                                              bool isRemote)
        {
            string uriScheme;
            string host;
            int port;
            string path;

            if (isRemote)
            {
                uriScheme = Uri.UriSchemeHttps;
                host = protocol.HostName;
                port = protocol.HttpsPort;
                path = protocol.BasePath + "/" + suffix + BindingStrings.RemoteProxySuffix;
            }
            else
            {
                uriScheme = Uri.UriSchemeNetPipe;
                host = "localhost";
                port = -1;
                path = protocol.HostName + "/" + protocol.BasePath + "/" + suffix;
            }

            UriBuilder builder = new UriBuilder(uriScheme, host, port, path);

            if (spnIdentity != null)
            {
                EndpointIdentity identity = EndpointIdentity.CreateSpnIdentity(spnIdentity);
                return new EndpointAddress(builder.Uri, identity);
            }
            else
            {
                return new EndpointAddress(builder.Uri);
            }
        }
 // The demand is not added now (in 4.5), to avoid a breaking change. To be considered in the next version.
 /*
 [PermissionSet(SecurityAction.Demand, Unrestricted = true)] // because we use ProtocolInformationReader, which is defined in a non-APTCA assembly; WSATs are not supported in partial trust, so customers should not be broken by this demand
 */
 void ReadExtendedProtocol(MemoryStream mem, uint cbTmProtocolData)
 {
     // Read the WSAT1.0 protoocol identifier
     Guid guid = SerializationUtils.ReadGuid(mem);
     if (guid == PluggableProtocol10.ProtocolGuid || guid == PluggableProtocol11.ProtocolGuid)
     {
         // This is the WS-AT extended whereabouts blob
         this.protocolInfo = new ProtocolInformationReader(mem);
     }
     else
     {
         // Some other gateway protocol... Skip the rest of the data
         SerializationUtils.IncrementPosition(mem, cbTmProtocolData - 16);
     }
 }