WsdlEndpointConversionContext.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Description / WsdlEndpointConversionContext.cs / 2 / WsdlEndpointConversionContext.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

namespace System.ServiceModel.Description 
{
    using System.IO; 
    using System.ServiceModel.Channels; 
    using System.Xml;
    using System.Collections.Generic; 
    using System.Collections.ObjectModel;
    using WsdlNS = System.Web.Services.Description;

    public class WsdlEndpointConversionContext 
    {
 
        readonly ServiceEndpoint endpoint; 
        readonly WsdlNS.Binding wsdlBinding;
        readonly WsdlNS.Port wsdlPort; 
        readonly WsdlContractConversionContext contractContext;

        readonly Dictionary wsdlOperationBindings;
        readonly Dictionary operationDescriptionBindings; 
        readonly Dictionary wsdlMessageBindings;
        readonly Dictionary wsdlFaultBindings; 
        readonly Dictionary messageDescriptionBindings; 
        readonly Dictionary faultDescriptionBindings;
 
        internal WsdlEndpointConversionContext(WsdlContractConversionContext contractContext, ServiceEndpoint endpoint, WsdlNS.Binding wsdlBinding, WsdlNS.Port wsdlport)
        {

            this.endpoint = endpoint; 
            this.wsdlBinding = wsdlBinding;
            this.wsdlPort = wsdlport; 
            this.contractContext = contractContext; 

            this.wsdlOperationBindings = new Dictionary(); 
            this.operationDescriptionBindings = new Dictionary();
            this.wsdlMessageBindings = new Dictionary();
            this.messageDescriptionBindings = new Dictionary();
            this.wsdlFaultBindings = new Dictionary(); 
            this.faultDescriptionBindings = new Dictionary();
        } 
 
        internal WsdlEndpointConversionContext(WsdlEndpointConversionContext bindingContext, ServiceEndpoint endpoint, WsdlNS.Port wsdlport)
        { 

            this.endpoint = endpoint;
            this.wsdlBinding = bindingContext.WsdlBinding;
            this.wsdlPort = wsdlport; 
            this.contractContext = bindingContext.contractContext;
 
            this.wsdlOperationBindings = bindingContext.wsdlOperationBindings; 
            this.operationDescriptionBindings = bindingContext.operationDescriptionBindings;
            this.wsdlMessageBindings = bindingContext.wsdlMessageBindings; 
            this.messageDescriptionBindings = bindingContext.messageDescriptionBindings;
            this.wsdlFaultBindings = bindingContext.wsdlFaultBindings;
            this.faultDescriptionBindings = bindingContext.faultDescriptionBindings;
        } 

        internal IEnumerable ExportExtensions 
        { 
            get
            { 
                foreach (IWsdlExportExtension extension in endpoint.Behaviors.FindAll())
                {
                    yield return extension;
                } 

                foreach (IWsdlExportExtension extension in endpoint.Binding.CreateBindingElements().FindAll()) 
                { 
                    yield return extension;
                } 

                foreach (IWsdlExportExtension extension in endpoint.Contract.Behaviors.FindAll())
                {
                    yield return extension; 
                }
 
                foreach (OperationDescription operation in endpoint.Contract.Operations) 
                {
                    if (!WsdlExporter.OperationIsExportable(operation)) 
                    {
                        continue;
                    }
 
                    // In 3.0SP1, the DCSOB and XSOB were moved from before to after the custom behaviors.  For
                    // IWsdlExportExtension compat, run them in the pre-SP1 order. 
                    // TEF QFE 367607 
                    Collection extensions = operation.Behaviors.FindAll();
                    for (int i = 0; i < extensions.Count;) 
                    {
                        if (WsdlExporter.IsBuiltInOperationBehavior(extensions[i]))
                        {
                            yield return extensions[i]; 
                            extensions.RemoveAt(i);
                        } 
                        else 
                        {
                            i++; 
                        }
                    }
                    foreach (IWsdlExportExtension extension in extensions)
                    { 
                        yield return extension;
                    } 
                } 
            }
        } 

        public ServiceEndpoint Endpoint { get { return endpoint; } }
        public WsdlNS.Binding WsdlBinding { get { return wsdlBinding; } }
        public WsdlNS.Port WsdlPort { get { return wsdlPort; } } 
        public WsdlContractConversionContext ContractConversionContext { get { return contractContext; } }
 
        public WsdlNS.OperationBinding GetOperationBinding(OperationDescription operation) 
        {
            return this.wsdlOperationBindings[operation]; 
        }

        public WsdlNS.MessageBinding GetMessageBinding(MessageDescription message)
        { 
            return this.wsdlMessageBindings[message];
        } 
 
        public WsdlNS.FaultBinding GetFaultBinding(FaultDescription fault)
        { 
            return this.wsdlFaultBindings[fault];
        }

        public OperationDescription GetOperationDescription(WsdlNS.OperationBinding operationBinding) 
        {
            return this.operationDescriptionBindings[operationBinding]; 
        } 

        public MessageDescription GetMessageDescription(WsdlNS.MessageBinding messageBinding) 
        {
            return this.messageDescriptionBindings[messageBinding];
        }
 
        public FaultDescription GetFaultDescription(WsdlNS.FaultBinding faultBinding)
        { 
            return this.faultDescriptionBindings[faultBinding]; 
        }
 
        // -------------------------------------------------------------------------------------------------

        internal void AddOperationBinding(OperationDescription operationDescription, WsdlNS.OperationBinding wsdlOperationBinding)
        { 
            this.wsdlOperationBindings.Add(operationDescription, wsdlOperationBinding);
            this.operationDescriptionBindings.Add(wsdlOperationBinding, operationDescription); 
        } 

        internal void AddMessageBinding(MessageDescription messageDescription, WsdlNS.MessageBinding wsdlMessageBinding) 
        {
            this.wsdlMessageBindings.Add(messageDescription, wsdlMessageBinding);
            this.messageDescriptionBindings.Add(wsdlMessageBinding, messageDescription);
        } 

        internal void AddFaultBinding(FaultDescription faultDescription, WsdlNS.FaultBinding wsdlFaultBinding) 
        { 
            this.wsdlFaultBindings.Add(faultDescription, wsdlFaultBinding);
            this.faultDescriptionBindings.Add(wsdlFaultBinding, faultDescription); 
        }
    }

} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK