I have a Variable class and and 3 subclasses: VariableBool, VariableLong and VariableDouble. Each subclass defines only a value member of the type of the suffix.
Now, I need to transfert objects based on these classes over WCF. I have multiple clients registering their variale to a server. Whenever a value changes on one client, it's updated in all other clients.
My question is: is there a way to do:
someVar.Value = anotherVar.Value;
regardless of the type, wihout having to check for type, e.g.:
VariableBool anotherVarBool = anotherVar as VariableBool;
if (anotherVarBool != null) {
(someVar as VariableBool).Value = anotherVar.Value;
}
// check other types...
What am I missing? Is there a patern of some kind? Could I use reflection? Also, I don't think I can use Generics because of the WCF (I've tried but I could make it work).
Thanks