public void SetStrategy<T>(Action<T> executor)
{
if (executor is Action<SomeOne> a)
{
_someOne = a;
} else if (executor is Action<SomeTwo> b)
{
_someTwo = b;
}
// ...
}
public void SetStrategy(Action<SomeOne> action) {
_someOne = action;
}
public void SetStrategy(Action<SomeTwo> action) {
_someTwo = action;
}
switch(executor) {
case Action<SomeOne> one:
_someOne = one;
break;
case Action<SomeTwo> two:
_someTwo = b;
break;
default:
throw new NotSupportedException($"{typeof(T).FullName} is not supprted");
}