I have the following actions:
abstract class AAction
{}
class BlueAction: AAction
{
void Foo1(){// do stuff}
void Foo2(){// do stuff}
}
and the plugins that should contain an action:
class APlugin
{
AAction _action;
APlugin(AAction action)
{
_action = action;
}
}
class BluePlugin: APlugin
{
BluePlugin(): base(new BlueAction());
{
}
voif Foo()
{
// do stuff with BlueAction's methods
((BlueAction)_action).Foo1();
((BlueAction)_action).Foo2();
}
}
I am trying to fit this design to a design pattern, with no luck.
What I just want is to force derived classes from APlugin to have an AAction
I could do simply this:
BlueAction act = (BlueAction)_action;
act.Foo1();
act.Foo2();
Using generics (as suggested) doesn’t allow me to have a list of APlugins which is something I really need.
But this is a no-go for me. Any ideas?
Use generics: