Command Pattern : How to pass parameters to a command?

前端 未结 13 1058
夕颜
夕颜 2020-12-07 16:43

My question is related to the command pattern, where we have the following abstraction (C# code) :

public interface ICommand
{
    void Execute();
}
<         


        
13条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 17:06

    There are some options:

    You could pass parameters by properties or constructor.

    Other option could be:

    interface ICommand
    {
        void Execute(T args);
    }
    

    And encapsulate all command parameters in a value object.

提交回复
热议问题