Implementing the IAdapterConfigurationProvider Interface |
The IAdapterConfigurationProvider Interface allows the developer to establish default configuration values for an adapter in order for it to function. These configuration values can include service URLs, Collections of values such as services, box sizes, Document Types, country codes, and other ad-hoc collections of values to be used by the adapter.
Click here for a list of all members of the IAdapterConfigurationProvider interface.
Below is an example of adding an adapter configuration setting via the IAdapterConfigurationProvider Interface. This code is adding two default URLs to the adapter's configuration to be used for communication to the external service.
using System.Collections.Generic; using PSI.Sox.Adapter; using PSI.Sox.Adapter.Interfaces; namespace PSI.Sox.CsAdapter { public class AdapterConfiguration: IAdapterConfigurationProvider { public List<ShipperSetting> GetDefaultShipperSettings() { return null; } public List<AdapterSetting> GetDefaultAdapterSettings() { var settings = new List<AdapterSetting>(); var ampAdminUrl = new AdapterSetting { Name = "Amp Admin Url", Symbol = "AMP_ADMIN_URL", Value = "http://localhost/amp/adminxml", ControlType = ControlType.Textbox, Description = "Amp Admin Url", GroupName = "Url" }; settings.Add(ampAdminUrl); var ampUrl = new AdapterSetting { Name = "Amp Url", Symbol = "AMP_URL", Value = "http://localhost/amp/xml", ControlType = ControlType.Textbox, Description = "Amp Url", GroupName = "Url" }; settings.Add(ampUrl); return settings; } } }
Once the adapter is complete and installed, the default configuration values added in the code above will be visible when editing the adapter in Management Studio. The control type, default text, and grouping within the form are controlled by the attributes specified in the example above.