Click here to Skip to main content
15,883,982 members
Articles / Productivity Apps and Services / Biztalk

TCP WCF LOB Adapter

Rate me:
Please Sign up or sign in to vote.
4.75/5 (6 votes)
11 Apr 2011CPOL2 min read 42.5K   714   7  
A BizTalk TCP WCF LOB adapter.
/// -----------------------------------------------------------------------------------------------------------
/// Module      :  ABAS400AdapterBindingElement.cs
/// Description :  Provides a base class for the configuration elements.
/// -----------------------------------------------------------------------------------------------------------

#region Using Directives
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Configuration;
using System.ServiceModel.Channels;
using System.Configuration;
using System.Globalization;

using Microsoft.ServiceModel.Channels.Common;
#endregion

namespace LOBAdapters.TCP
{
    public class AdapterBindingElement : StandardBindingElement
    {
        private ConfigurationPropertyCollection properties;

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the ABAS400AdapterBindingElement class
        /// </summary>
        public AdapterBindingElement()
            : base(null)
        {
        }


        /// <summary>
        /// Initializes a new instance of the ABAS400AdapterBindingElement class with a configuration name
        /// </summary>
        public AdapterBindingElement(string configurationName)
            : base(configurationName)
        {
        }

        #endregion Constructors

        #region Custom Generated Properties

        [System.Configuration.ConfigurationProperty("enableConnectionPolling", DefaultValue = false)]
        public bool EnableConnectionPolling
        {
            get
            {
                return ((bool)(base["EnableConnectionPolling"]));
            }
            set
            {
                base["EnableConnectionPolling"] = value;
            }
        }

        #endregion Custom Generated Properties

        #region Protected Properties

        /// <summary>
        /// Gets the type of the BindingElement
        /// </summary>
        protected override Type BindingElementType
        {
            get
            {
                return typeof(AdapterBindingObject);
            }
        }

        #endregion Protected Properties

        #region StandardBindingElement Members

        /// <summary>
        /// Initializes the binding with the configuration properties
        /// </summary>
        protected override void InitializeFrom(Binding binding)
        {
            base.InitializeFrom(binding);
            AdapterBindingObject adapterBinding = (AdapterBindingObject)binding;
            this["EnableConnectionPolling"] = adapterBinding.EnableConnectionPolling;
        }

        /// <summary>
        /// Applies the configuration
        /// </summary>
        protected override void OnApplyConfiguration(Binding binding)
        {
            if (binding == null)
                throw new ArgumentNullException("binding");

            AdapterBindingObject adapterBinding = (AdapterBindingObject)binding;
            adapterBinding.EnableConnectionPolling = (System.Boolean)this["EnableConnectionPolling"];
        }

        /// <summary>
        /// Returns a collection of the configuration properties
        /// </summary>
        protected override ConfigurationPropertyCollection Properties
        {
            get
            {
                if (this.properties == null)
                {
                    ConfigurationPropertyCollection configProperties = base.Properties;
                    configProperties.Add(new ConfigurationProperty("EnableConnectionPolling", typeof(System.Boolean), false, null, null, ConfigurationPropertyOptions.None));
                    this.properties = configProperties;
                }
                return this.properties;
            }
        }


        #endregion StandardBindingElement Members
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Program Manager
Jordan Jordan
Self-motivated, creative and results-driven technology executive who is well versed and experienced in leveraging an end-to-end, holistic vision of business objectives to drive full technology / business alignment.

Skilled in grasping business needs and sudden market demand’s shifts by diving into latest business / technology trends, selecting the best fit business model / technology to create a positive reflection on revenue. His multifaceted approach has enabled him to deliver key solutions across a wide range of disciplines including design, development, UX / UI, Business Intelligence.

Technical Specialties are in .Net, Java, Spring Boot, Maven, MS SQL, Oracle, Postgesql, Redis, Javascript, Bootstrap, Angular 2.

Comments and Discussions