MsmqIntegrationBinding.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 / MsmqIntegration / MsmqIntegrationBinding.cs / 1 / MsmqIntegrationBinding.cs

                            //------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel.MsmqIntegration
{ 
    using System;
    using System.ComponentModel; 
    using System.ServiceModel; 
    using System.Text;
    using System.Collections.Generic; 
    using System.Collections.ObjectModel;
    using System.Configuration;
    using System.Globalization;
    using System.Net; 
    using System.Net.Security;
    using System.Runtime.Serialization; 
    using System.Security.Principal; 
    using System.ServiceModel.Channels;
    using Config = System.ServiceModel.Configuration; 
    using System.ServiceModel.Security;

    using System.Xml;
 
    public class MsmqIntegrationBinding : MsmqBindingBase
    { 
        // private BindingElements 
        MsmqIntegrationSecurity security = new MsmqIntegrationSecurity();
 
        public MsmqIntegrationBinding()
        {
            Initialize();
        } 

        public MsmqIntegrationBinding(string configurationName) 
        { 
            Initialize();
            ApplyConfiguration(configurationName); 
        }

        public MsmqIntegrationBinding(MsmqIntegrationSecurityMode securityMode)
        { 
            if (! MsmqIntegrationSecurityModeHelper.IsDefined(securityMode))
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException("securityMode", (int)securityMode, typeof(MsmqIntegrationSecurityMode))); 
            Initialize(); 
            this.security.Mode = securityMode;
        } 

        public MsmqIntegrationSecurity Security
        {
            get { return this.security; } 
        }
 
        internal Type[] TargetSerializationTypes 
        {
            get 
            {
                return (transport as MsmqIntegrationBindingElement).TargetSerializationTypes;
            }
            set 
            {
                (transport as MsmqIntegrationBindingElement).TargetSerializationTypes = value; 
            } 
        }
 
        public MsmqMessageSerializationFormat SerializationFormat
        {
            get { return (transport as MsmqIntegrationBindingElement).SerializationFormat; }
            set { (transport as MsmqIntegrationBindingElement).SerializationFormat = value; } 
        }
 
        void Initialize() 
        {
            transport = new MsmqIntegrationBindingElement(); 
        }

        void ApplyConfiguration(string configurationName)
        { 
            Config.MsmqIntegrationBindingCollectionElement section = Config.MsmqIntegrationBindingCollectionElement.GetBindingCollectionElement();
            Config.MsmqIntegrationBindingElement element = section.Bindings[configurationName]; 
            if (element == null) 
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException( 
                    SR.GetString(SR.ConfigInvalidBindingConfigurationName,
                                 configurationName,
                                 Config.ConfigurationStrings.MsmqIntegrationBindingCollectionElementName)));
            } 
            else
            { 
                element.ApplyConfiguration(this); 
            }
        } 

        public override BindingElementCollection CreateBindingElements()
        {   // return collection of BindingElements
            BindingElementCollection bindingElements = new BindingElementCollection(); 
            // order of BindingElements is important
            // add transport 
            this.security.ConfigureTransportSecurity(transport); 
            bindingElements.Add(transport);
 
            return bindingElements.Clone();
        }
    }
} 

// 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