Ben*_*Ben 3 c# coding-style fluent-interface
public static class Th
{
public static T e<T>(T theObject) where T : class
{
return theObject;
}
}
public static class ObjectExtensions
{
public static bool Is<T>(this T o, Func<T, bool> a) where T : class
{
return a(o);
}
}
//...
//logic in a method somewhere
Func<string, bool> valid = property => _myService.SomeValidationMethod(property);
if (Th.e(_request.Property).Is(valid))
{
//do something
}
Run Code Online (Sandbox Code Playgroud)
这段代码适合生产吗?为什么?
编辑:感谢您的所有意见.我希望你阅读我对C#语法的延伸,以及阅读你的回答时的突破点.
| 归档时间: |
|
| 查看次数: |
436 次 |
| 最近记录: |