2009-12-14 89 views

回答

4

我想這應該是command pattern的一個版本,它根據提供的消息對相關域對象執行必要的操作。例如像

public PromoteEmployeeCommand : ICommand { 
    private readonly PromotionMessage _message; 
    private readonly IEmployeeRepository _repository; 

    public PromoteEmployeeCommand(PromotionMessage message, 
            IEmployeeRepository repository) { 
      _message = message; 
      _repository = repository; 
    } 

    public void Execute() { 
      /* Get the employee, give them a rise etc... */ 
    } 
} 

從編輯模型的映射的東西會解決了一些命令消息的要求(例如給員工的上升,通知他們的經理,添加備註工資等),可以被調用。

此方法的優點是它可以將您的域模型與Edit模型公開的任何表示關注點隔離。