2. Step 2: UI Logical Grouping
In this step, you will modify the HotelAdapterBindingElement and HotelAdapterUri
classes to logically group the binding and connection properties that
you created in step 1. You will create three categories and arrange the
properties within these categories, as shown in Table 8.
Table 8. Adapter Property Categories
Property Name | Category |
---|
EnableConnectionPooling | Misc |
Application | Connection |
EnableAuthentication | Connection |
Host | Connection |
PollingPeriod | Inbound |
When you complete this step
and build the project, the binding and connection properties will be
grouped and presented in the Add Adapter Service Reference plug-in and
Consume Adapter Service add-in, as shown in Figures 8 and 9.
Although categorizing
properties is optional, we recommend that you don't ignore this step.
The reasoning is simple—categorizing improves user experience, since in
many if not most cases adapter consumers will configure adapters using
the UI tools.
As you can guess, the implementation is fairly straightforward and doesn't require more than applying the System.ComponentModel.Category attribute to the custom properties. Let's start with the HotelAdapterBindingElement class:
In Visual Studio, open the HotelAdapterBindingElement.cs file.
To
assign the Misc category to the EnableConnectionPooling property, place
the [System.ComponentModel.Category("")] line of code at the beginning
of the EnableConnectionPooling implementation, as shown here:
[System.Configuration.ConfigurationProperty("enableConnectionPooling",
DefaultValue = true)]
public bool EnableConnectionPooling
{
get
{
return ((bool)(base["EnableConnectionPooling"]));
}
set
{
base["EnableConnectionPooling"] = value;
}
}
Specify the Inbound category for the PollingPeriod property by placing the [System.ComponentModel.Category("Inbound")] line of code at the beginning of the PollingPeriod property, as shown in the following code snippet:
[System.ComponentModel.Category("Inbound")]
[System.Configuration.ConfigurationProperty("pollingPeriod",
DefaultValue = 10)]
public int PollingPeriod
{
get
{
return ((string)(base["pollingPeriod"]));
}
set
{
base["pollingPeriod"] = value;
}
}
Follow a similar procedure for the HotelAdapterConnectionUri class:
In Visual Studio, open the HotelAdapterConnectionUri.cs file.
Expand the Custom Generated Properties region, and apply the [System.ComponentMode.Category("Connection")] attribute to each of the properties in the region. When you finish, the Custom Generated Properties region should match the following code snippet:
#region Custom Generated Properties
[System.ComponentModel.Category("Connection")]
public string Application
{
get
{
return this.application;
}
set
{
this.application = value;
}
}
[System.ComponentModel.Category("Connection")]
public bool EnableAuthentication
{
get
{
return this.enableAuthentication;
}
set
{
this.enableAuthentication = value;
}
}
[System.ComponentModel.Category("Connection")]
public string Host
{
get
{
return this.host;
}
set
{
this.host = value;
}
}
#endregion Custom Generated Properties
Save and build the project.
In the next step, you will
work with the classes and interfaces responsible for establishing and
managing connection to the LOB systems.