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 example, some log files 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 RegEx should always return an address and a data.
I want to make this RegEx controllable from the application. I don't want to hardcode the RegEx of each format in the source code. The user should be able to modify an existing RegEx or add a new RegEx for a new kind of log file. I should provid开发者_JAVA百科e 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 don't have much idea how to implement.
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.
精彩评论