Monday, May 21, 2007

Configuring the Connection Monitor Application Block

This configuration information defines the logical networks and physical network adapters that you want to monitor
<ConnectionMonitor>
<Networks>
<add Name="Intranet" Address="http://contoso"/>
<add Name="Internet" Address="http://www.microsoft.com"/>
</Networks>
<Connections>
<add Type="WiredConnection" Price="1"/>
</Connections>
</ConnectionMonitor>
Following values can use for the Type attribute
  • NicConnection. The application block uses the NicConnection class to monitor any network interface connection—for example, an Ethernet card or wireless adapter. This class provides the capability to detect if the application has a connection to a network.
  • WiredConnection. The application block uses the WiredConnection class to monitor connectivity to Ethernet adapters.
  • WirelessConnection. The application block uses the WirelessConnection class to monitor connectivity to wireless network adapters.
  • DesktopConnection. The application block uses the DesktopConnection class to monitor connectivity to local services (you can manually set the connection state of this class).
Configure the Connection Monitor Application Block
Define a configuration section for the application block in the application configuration file. To do this, add a <section> node to the <configSections> node of your App.config file
<configSections>
<section name="ConnectionMonitor" type="Microsoft.Practices.SmartClient.ConnectionMonitor.Configuration.ConnectionSettingsSection, Microsoft.Practices.SmartClient.ConnectionMonitor" />
</configSections>
Create the application block configuration section and define your logical networks. Configure each logical network inside a node using an element.
<ConnectionMonitor>
<Networks>
<add Name="Intranet" Address="http://intranet"/>
<add Name="Internet" Address="http://www.microsoft.com"/>
</Networks>
</ConnectionMonitor>
If you want to monitor physical network adapters, add the configuration information for the network adapters inside a <connections> element.
<ConnectionMonitor>
<Connections>
<add Type="WiredConnection" Price="1"/>
<add Type="WirelessConnection" Price="2"/>
</Connections>
</ConnectionMonitor>
Optionally, specify the type name of the network status strategy to use to monitor the connection status of the logical network.
<ConnectionMonitor>
<Networks StrategyType="ConnectionModule.CustomNetworkStatusStrategy, ConnectionModule">
<add Name="Intranet" Address="http://intranet"/>
<add Name="Internet" Address="http://www.microsoft.com"/>
</Networks>
</ConnectionMonitor>

No comments: