Share via


How to: Surface an adapter setting as adapter binding property

WCF LOB Adapter SDK uses the properties defined in following classes for configuring connection pool, metadata cache and other adapter aspects.  If adapter developer wants the adapter consumer to set these properties through a configuration file, these settings must be surfaced as a binding property. 

Microsoft.ServiceModel.Channels.Common.AdapterSettings

 

Microsoft.ServiceModel.Channels.Common.AdapterEnvironmentSettings

 

If you are constructing an adapter from the wizard, you can specify the binding properties on Adapter Properties page.  The properties are then specified in the following classes -

  • Microsoft.ServiceModel.Channels.Common.Adapter derived class
  • Microsoft.ServiceModel.Channels.Common.AdapterBinding derived class
  • System.ServiceModel.Configuration.StandardBindingElement derived class

You need to make change in the Adapter derived class as follows:

  • Remove the generated private variables for properties that you want to get/set from adapter settings
  • Update the getter/setter methods to read/write values from/to adapter settings

    public class SampleAdapter : Adapter

    {

        // Initializes the AdapterEnvironmentSettings class

        private static AdapterEnvironmentSettings environmentSettings = new AdapterEnvironmentSettings();

        private int count;

        /// <summary>

        /// Initializes a new instance of the SampleAdapter class

        /// </summary>

  public SampleAdapter() : base(environmentSettings)

        {

            // disable performance counters by default

            environmentSettings.PerformanceCounters.Enabled = false;

            // enable connection pooling by default

            this.Settings.ConnectionPool.EnablePooling = true;

        }

        /// <summary>

        /// Initializes a new instance of the SampleAdapter class with a binding

        /// </summary>

        public SampleAdapter(SampleAdapter binding) : base(binding)

        {

            this.Count = binding.Count;

            this.EnablePerfCounters = binding.EnablePerfCounters;

  this.EnableConnectionPooling = binding.EnableConnectionPooling;

        }

        [System.Configuration.ConfigurationProperty("count", DefaultValue = 4)]

        public int Count

        {

            get { return this.count; }

            set { this.count = value; }

        }

        [System.Configuration.ConfigurationProperty("enablePerfCounters", DefaultValue = false)]

        public bool EnablePerfCounters

        {

            get { return environmentSettings.PerformanceCounters.Enabled; }

            set { environmentSettings.PerformanceCounters.Enabled = value; }

        }

        [System.Configuration.ConfigurationProperty("enableConnectionPooling", DefaultValue = true)]

        public bool EnableConnectionPooling

        {

            get { return this.Settings.ConnectionPool.EnablePooling; }

            set { this.Settings.ConnectionPool.EnablePooling = value; }

        }

    }

Comments

  • Anonymous
    July 08, 2007
    One of the key features of WCF LOB Adapter SDK is target system’s Connection Management. This posts talk

  • Anonymous
    July 08, 2007
    After WCF LOB Adapter SDK is installed on the system, the Adapter Developer can use the WCF LOB Adapter

  • Anonymous
    October 07, 2007
    Background: After we downloaded WCF LOB Adapter SDK and read my previous post. You will find all the...