コード例 #1
0
        public void GetListenAddressAndContext(out EndpointAddress listenAddress, out IDictionary <string, string> context)
        {
            // we expect the callback address to be already set when this is called
            if (this.CallbackAddress == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("callbackaddress");
            }
            EndpointAddressBuilder builder       = new EndpointAddressBuilder(this.CallbackAddress);
            AddressHeader          contextHeader = null;
            int contextHeaderIndex = -1;

            for (int i = 0; i < builder.Headers.Count; ++i)
            {
                if (builder.Headers[i].Name == ContextMessageHeader.ContextHeaderName && builder.Headers[i].Namespace == ContextMessageHeader.ContextHeaderNamespace)
                {
                    if (contextHeader != null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(SR.GetString(SR.MultipleContextHeadersFoundInCallbackAddress)));
                    }
                    contextHeader      = builder.Headers[i];
                    contextHeaderIndex = i;
                }
            }
            if (contextHeader != null)
            {
                builder.Headers.RemoveAt(contextHeaderIndex);
            }
            context       = (contextHeader != null) ? ContextMessageHeader.ParseContextHeader(contextHeader.GetAddressHeaderReader()).Context : null;
            listenAddress = builder.ToEndpointAddress();
        }
コード例 #2
0
        public void GetListenAddressAndContext(out EndpointAddress listenAddress, out IDictionary <string, string> context)
        {
            if (this.CallbackAddress == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("callbackaddress");
            }
            EndpointAddressBuilder builder = new EndpointAddressBuilder(this.CallbackAddress);
            AddressHeader          header  = null;
            int index = -1;

            for (int i = 0; i < builder.Headers.Count; i++)
            {
                if ((builder.Headers[i].Name == "Context") && (builder.Headers[i].Namespace == "http://schemas.microsoft.com/ws/2006/05/context"))
                {
                    if (header != null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(System.ServiceModel.SR.GetString("MultipleContextHeadersFoundInCallbackAddress")));
                    }
                    header = builder.Headers[i];
                    index  = i;
                }
            }
            if (header != null)
            {
                builder.Headers.RemoveAt(index);
            }
            context       = (header != null) ? ContextMessageHeader.ParseContextHeader(header.GetAddressHeaderReader()).Context : null;
            listenAddress = builder.ToEndpointAddress();
        }