C# 规格模式示例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1436663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 16:31:01  来源:igfitidea点击:

Specification Pattern Example

c#.netdesign-patternsspecification-pattern

提问by Kane

After reading a series of blogs (hereand here) by Chris Missal from LosTechies.com on the Specification Pattern I am am really interested in finding more complete examples. Does anyone know where I could find a more fleshed out example or perhaps an open source project that uses this pattern?

在阅读了LosTechies.com 的 Chris Missal 撰写的关于规范模式的一系列博客(这里这里)之后,我真的很想找到更完整的示例。有谁知道我在哪里可以找到一个更充实的例子或者一个使用这种模式的开源项目?

采纳答案by Dr Herbie

Also take a look at the Dimecasts 'Learning the Specification pattern'for a walkthrough of an example.

还可以查看 Dimecasts 的“学习规范模式”以获取示例演练。

Having learned the Specification pattern through the same blogs as you listed, I'm not yet convinced. It could just be that the examples are too simplistic so it seems more work that it's worth. A good, extensive example that shows come genuine benefit would be nice.

通过与您列出的相同的博客学习了规范模式,我还不相信。可能只是这些例子太简单了,所以似乎值得做更多的工作。一个很好的、广泛的例子表明真正的好处会很好。

回答by Brandon E Taylor

Take a look at the "Specifications" paper authored by Eric Evans and Martin Fowler.

看看由 Eric Evans 和 Martin Fowler 撰写的“规范”论文。

The following blog article - "The Specification Pattern" - might also be of use to you.

以下博客文章 - “规范模式” - 也可能对您有用。

回答by JTech

I actually think the Wikipedia page (at the time of this post) is a more concise and easier to absorb example of using the Specification pattern...lostechies.com actually references it.

我实际上认为维基百科页面(在这篇文章的时间)是一个更简洁、更容易吸收的使用规范模式的例子...... lostechies.com 实际上引用了它。

Here is the link: Wikipedia: The Specification Pattern

这是链接:维基百科:规范模式

回答by fabriciorissetto

For me one of the best examples is the Route Specificationthat Eric Evans uses on his book.

对我来说,最好的例子之一是Route SpecificationEric Evans 在他的书中使用的。

The source code is here, it is written in Java but is very easy to understand and translate to C#.

源代码在这里,它是用 Java 编写的,但很容易理解并转换为 C#。

回答by GorkemHalulu

You can find many sample projects about design patterns (Specification Patternas well) herefrom "Professional ASP.NET Design Patterns"book.

你可以找到关于设计模式的许多示例项目(规格模式以及)这里“专业ASP.NET设计模式”的书。