Skip to main content
5 events
when toggle format what by license comment
Jul 7, 2015 at 16:53 comment added mgw854 You could also define a non-generic interface IModelSetting that ModelSetting<T> extends. Then your Dictionary is a little more strongly typed (you know you can only have IModelSettings). Alternatively, you could use an abstract class. I've done both in similar situations.
Jul 7, 2015 at 15:18 vote accept rookie
Jul 7, 2015 at 15:18 comment added rookie I decided to use a Dictionary<string, object> and hide the casting details with methods like public void AddSetting<T>(string key, ModelSetting<T> value). Thanks again!
Jul 7, 2015 at 14:56 comment added rookie One more question before I accept your answer. How should I store the settings in a collection? What I'd like is a mapping of string values to ModelSetting objects (i.e. a Dictionary<string, ModelSetting>). Is this possible?
Jul 7, 2015 at 14:45 history answered Ben Aaronson CC BY-SA 3.0