views:

57

answers:

1

Hello,

I am building a GUI application that will be the front-end for an XML configuration file.

The XML structure defines a set of object instances. That is, type names, and property values that should be instantiated in the consuming application (windows service).

So there are three layers:

ConfigurationObject <--> ComponentObjects <--> PropertyGrid

The ConfigurationObject serializes into the proper XML format for the windows service. The ComponentObjects are the same types that are used by the windows service.

The problem I am having is determining the best way to keep all three layers in sync.

My first implementation I would update individual properties when they were changed. However this approach didnt work very well when I need to update complex objects to the UI (Although I believe I know what the problem was now)

My current approach involves using TypeConverters to convert between the ConfigurationObject and the ComponentObjects which works well until a realized that my current logic is ignoring the BrowseableAttribute (since i simply iterate over all the ComponentObject properties when converting to a ConfigurationObject)

So before I spend anymore time on my current approach I want to be sure that I am on the right track. Is there a simpler approach? IS there some model/design pattern I can use in such a situation?

Thanks, Karl

+1  A: 

I was able to figured out the missing pieces to my problem.

I Created a TypeDescriptionProvider for the ConfigurationObject this provider was used to map between the ComponentObjects Properties and the ConfigurationObject's representation of those same properties.

The ComponentObjects were decorated with TypeConverters which converted to and from String's

The real key was to assign the ConfigurationObject to the PropertyGrid and not the ComponentObjects.

Karl