Hello eveyone... In my app, I have deal with several different "parameters", which derive from IParameter
interface, and also ParamBase
abstract base class. I currently have two different parameter types, call them FooParameter
and BarParameter
, which both derive from ParamBase
. Obviously, I can treat them both as IParameter
s when I need to deal with them generically, or detect their specific type when I need to handle their specific functionality.
My question lies in specific FooParameter
s. I currently have a few specific ones with their own classes which derive from FooParameter
, we'll call them FP12
, FP13
, FP14
, etc. These all have certain characteristics, which make me treat them differently in the UI. (Most have names associated with the individual bits, or ranges of bits). Note that these specific, derived FP's have no additional data associated with them, only properties (which refer to the same data in different ways) or methods.
Now, I'd like to keep all of these parameters in a Dictionary<String, IParameter>
for easy generic access. The problem is, if I want to refer to a specific one with the special GUI functions, I can't write:
FP12 fp12 = (FP12)paramList["FP12"]
because you can't downcast to a derived type (rightfully so). But in my case, I didn't add any data, so the cast would theoretically work.
What type of programming model should I be using instead? Thanks!