views:

16

answers:

1

My Project

I'm writing a Winform application using VS C# 2.0 which consists in several libraries and two executables, each in its own project file and all part of the same solution.

Each project has its own Settings Class which configuration parameters. Some parameters are project specific, some are needed by more than one project (but none for all), and others depend on the model of a hardware device connected via USB to the user machine (and are selected at runtime).

The Setting Class consists on enumerations, properties and Load and Save methods.

Currently I have a form with a property grid which instantiates all the settings from all the classes and lets the user change the configuration. It belongs to the main executable project.

My problem

I need a way for the users to configure the whole application (let's call it a configurator), so I tried to create another project which would have the form with the property grid, but ended with a circular reference problem between the configurator and my main executable. The configurator needs to run on its own or be called from the main executable.

Also, I don't know a good way to replicate changes to the value of a common parameter to its counterparts. For instance, if parameter p is common to the settings classes of projects A and B, when a user changes A.p value, the configurator would have to change B.p value (and the same for the inverse). The only solution I've thought to resolve this involves a nightmare of if clauses on the PropertyValueChanged event handler of the property grid.

Thanks, Heiddy

A: 

In order to reduce circular dependency, you must include Abstract classes and Interfaces accordingly.

Base Library: consists of all "Data" classes, implementing IPropertyChangedNoitifier and which should be consistent throughout. Loading/Saving of configuration should be saved in this library itself.

Configuration Library: References Base Library and does configuration changes and invokes certain events about change of configuration. However this project must only contain the UI to configure;

Configuration Project: loads and executes UI of Configuration Library.

Actual Project: References Base Library and Configuration Library, and you can load Configuration UI from this project as well as from other project.

Talking about run time replication of settings, you can watch events of File content changes through File System Watcher and reload your config after certain millseconds once the file changes are detected.

Akash Kava
Thanks for your answer!I've just began to read about implementing IpropertyChangedNotifier.
Heiddy Urbina