Skip to content

Raspberry.IO.GeneralPurpose.Configuration.GpioConnectionConfigurationSection

raspberry-sharp edited this page Oct 14, 2012 · 7 revisions

The GpioConnectionConfigurationSection class implements a configuration section dedicated to configuration of GPIO access.

.config File

Section definition

<section name="gpioConnection"
         type="Raspberry.IO.GeneralPurpose.Configuration.GpioConnectionConfigurationSection, Raspberry.IO.GeneralPurpose" />

Section usage

<gpioConnection driver="*driverTypeAndAssembly*" />
Parameters
  • driverTypeAndAssembly: the fully qualified name of the IConnectionDriver implementation.

Sample

<configSections>
  <section name="gpioConnection" 
           type="Raspberry.IO.GeneralPurpose.Configuration.GpioConnectionConfigurationSection, Raspberry.IO.GeneralPurpose" />
</configSections>

<gpioConnection driver="Raspberry.IO.GeneralPurpose.FileConnectionDriver, Raspberry.IO.GeneralPurpose" />

Usage in Applications

Value of driver attribute of gpioConnection section element is used by GpioConnection to load a default connection driver if not specified in initializer. By default, MemoryConnectionDriver is used.

GpioConnectionConfigurationSection may also be used as follow:

IConnectionDriver driver;
var configurationSection = ConfigurationManager.GetSection("gpioConnection") as GpioConnectionConfigurationSection;
if (configurationSection != null && !string.IsNullOrEmpty(configurationSection.DriverTypeName))
  driver = (IConnectionDriver) Activator.CreateInstance(Type.GetType(configurationSection.DriverTypeName, true));
else
  driver = new MemoryConnectionDriver();
Clone this wiki locally