views:

72

answers:

1

Hi

I have a program in C# WPF which analyzes certain log files. Each log contains lines of data in a format which contains an address and a data offset.

For eg some log file can have the format,

mmio address : data

or some can have the format

write address : data

There can be many such formats, but rest assured that each line when parsed with an appropriate regx should always return an address and a data.

I want to make this regex controllable from the application. I dont want to hardcode the regex of each format in the sourcecode. The user should be able to modify an existing regex or add a new regex for a new kind of log file. I should provide him something like a table from which he can select a particular row or add a new row for a new log file

Table:

Name of Log - RegEx

MMIO Log - MMIO ([0-9]{8}) : ([0-9]{8}) --> Radio Button

Write Log - Write ([0-9]{8}) : ([0-9]{8}) --> Radio Button

How can i do this? Can i store this in some kind of config file or use a plugin model which i dont have much idea how to implement.

Thanks

+1  A: 

A plug-in system is absolute overkill. Just use the App.config to store the expressions and show them in a combo box or something similar. Have a look at this great article series how to access the configuration. Additional reference for the System.Configuration namespace comes from the MSDN.

Daniel Brückner