I'm trying to create an object called Settings that will store a set of values to be used throughout my application as well as read and write them in the registry. So far I've defined a singleton called clsSettings with the following attributes:
public string RegistryPath //set this property to determine where the values are stored in the registry
public Hashtable Values //key-value pair where the key is the name of the setting (eg. "InputDir") and value is the value of that setting (eg. "C:\test")
public static GetInstance //Returns the persistent instance of my singleton clsSettings object
public bool Read (string default) //iterates through Values and looking for each Key in RegistryPath and assigning it to Value (not yet implemented)
public bool Write //iterates through Values and writes each Key to RegistryPath creating registry keys as necessary (not yet implemented)
I have a few questions:
1) Is this the best design for what I'm trying to do?
2) What's the easiest way to pull a value out of a hashtable?
3) Ideally, I would like to access my values like this: Settings.Values["InputDir"] = "c:\test". Is there an existing way for me to do this or would I have to build my own?
4) Do I have to explicitly destroy my singleton?
As you can tell I'm new to C# and appreciate any help you can offer. :)