Project Silk 中的处理程序模式
我正在查看 Project Silk 项目的源代码,发现有一个我以前从未见过的“处理程序”模式。首先 - 这个 2009 年的链接暗示了它,但让我悬而未决。
示例显示的是一个单一方法类,其中每个class 代表相关存储库类中每个方法的一个方法。类的命名类似于方法名称。
public class GetFillupsForVehicle
{
private readonly IFillupRepository _fillupRepository;
public GetFillupsForVehicle(IFillupRepository fillupRepository)
{
_fillupRepository = fillupRepository;
}
public virtual IEnumerable<FillupEntry> Execute(int vehicleId)
{
try
{
var fillups = _fillupRepository
.GetFillups(vehicleId)
.OrderBy(f => f.Date)
.ToList();
return new ReadOnlyCollection<FillupEntry>(fillups);
}
catch (InvalidOperationException ex)
{
throw new BusinessServicesException(Resources.UnableToRetireveFillupsExceptionMessage, ex);
}
}
}
有人可以解释一下这种模式或向我指出一些我可以阅读以了解更多信息的内容吗?
谢谢, 保罗
I am looking at the source for the Project Silk project and there is a "handler" pattern that I have not seen before. First - this link from 2009 alludes to it but leaves me hanging
What the sample shows is a one method class where each class represents one method for each method in a related repository class. The classes are named like method names.
public class GetFillupsForVehicle
{
private readonly IFillupRepository _fillupRepository;
public GetFillupsForVehicle(IFillupRepository fillupRepository)
{
_fillupRepository = fillupRepository;
}
public virtual IEnumerable<FillupEntry> Execute(int vehicleId)
{
try
{
var fillups = _fillupRepository
.GetFillups(vehicleId)
.OrderBy(f => f.Date)
.ToList();
return new ReadOnlyCollection<FillupEntry>(fillups);
}
catch (InvalidOperationException ex)
{
throw new BusinessServicesException(Resources.UnableToRetireveFillupsExceptionMessage, ex);
}
}
}
Could someone explain this pattern or point me to something that I could read to learn more?
Thanks,
Paul
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅有关 Project Silk 的信息,该信息现在与采纳。
在我从 Microsoft 在 Project Silk 上提供的 PDF 文档中重新发布的代码片段中,将帮助您了解它的使用方式。据我所知,它更多地被认为是在业务领域级别触发事件的脚手架。
另请参阅此特定帖子,它可能会阐明他们要去的地方。
<代码>
<代码>
Please refer to this information about Project Silk which will be more relevant now to adopt.
In the code snippet which I have reposted from the PDF document provided by Microsoft on the Project Silk will help you understand how its being consumed. According to me its being considered more as scaffolding towards triggering the event at Business Domain level.
Also refer to this specific post which might be throwing light where they are heading to.