Programming tools work best when they are integrated into a larger framework. Services within such a framework might include logging, localization and configuration tools. When constructing DevExpressContrib, I did not want to ignore these services, nor did I want to force someone into a specific set of tools. For instance, logging can be done using Microsoft Enterprise Library Logging Block, Log4N, NLog, custom logging, etc.

To help support these tools I abstracted out those calls which DevExpressContrib invokes and placed them into an interface - IServicesHelper. DevExpressContrib comes with a default implementation (DefaultServicesHelper) which is used if you don't set a custom implementation.

There are currently three services which need to be supported when you implement a custom IServicesHelper; logging, localization and configuration.

Logging: Logging of warnings, errors, fatal errors, exceptions and informational messages is handled via a series of LogXxx methods. Examples are LogError, LogException, etc. DefaultServicesHelper leaves these methods empty - no logging is done.

Localization: Obtaining localized values for strings is done via the GetString methods. DefaultServicesHelper obtains these values from the default assembly resource file.

Configuration: String values that need to be stored are read and written via the ReadConfigString and WriteConfigString methods. DefaultServicesHelper reads and writes to the app.config file. Of course, this will be problematic if the application is installed to the standard "Program Files" directory under Vista or a non-administrative account. You can implement these methods to read/write to custom configuration files, the registry or a database.

See the DefaultServicesHelper for an example of how to implement your own custom IServicesHelper.

 

Back to task-based help.