The first is type safe, the second is not. Therefore, if I choose between these two options, I would choose the first.
, ?
Action, ?
"GetDetailsForNotification", , SendNotificationForAction.
- , , , , :
interface IAction
{
string GetDetailsForNotification();
}
public class Action : IAction{
public string GetDetailsForNotification()
{
return "details from Action";
}
}
public class Action2 : IAction{
public string GetDetailsForNotification()
{
return "details from Action2";
}
}
public void SendNotificationForAction(IAction action) {
var details = action.GetDetailsForNotification();
...
}