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 -
You need to make change in the Adapter derived class as follows:
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;
}
/// Initializes a new instance of the SampleAdapter class with a binding
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; }