tags:

views:

31

answers:

1

Hello,

I've been developing a configuration system that would allow me to easily version and access config values across multiple destinations and I'm having sort of a design issue.

The problem goes something like this. I have a class lets call it FooConfig. This class is basically a data transfer object, all it has is properties. Now the config system is able to take any class (in this case it will take FooConfig) and reflect over all the properties that have get and set methods. It will then take those values and populate another class called ConfigSettings. The ConfigSettings class basically holds a collection of Property structs and some other stuff but that isn't important.

The problem I'm facing is that I have a struct (called Property) that holds the individual data collected from FooConfig and is being held inside of ConfigSettings. This was fine when I was storing data in a simple key value scenario but now I need to be able to store collections and single values in the Property struct.

So I was wondering if anyone has any ideas on how to manage a collection and a single value in a nice clean way. Normally I would create two separate structs but the Property struct must be accessible from the ConfigSettings class and I need Immutability.

A: 

for your Key/Value Collection you can use a Dictionnary object.

For example

Class ConfigSettings
{
     struct Property
     {
         Dictionary<int, string> mydict = new Dictionary<int,string>();
         int somevalue;
     }
}

Dictionaries are quite easy to manage and keep track of items inside.

Tony