我知道这可能听起来很愚蠢,但我发现很难理解服务层的需求及其与业务层的差异.
因此,我们使用asp.net mvc 2并拥有数据访问层,它对数据库进行所有查询,然后我们拥有业务层,其中包含需要完成的业务逻辑和验证.最后我们有Presentation Layer,基本上有所有的视图.此外,我们还在不同的文件夹中有一些帮助程序,DTO和viewmodel类作为我们库的一部分.但我试图阅读有关架构的内容,似乎服务层是架构的重要组成部分.
我所理解的是服务层是调用所有功能的东西.但我真的不能在我们的应用程序中看到Service层的需要吗?或者它可能已经存在并且我看不到它......任何人都可以用一个例子解释一个服务层是如何重要的?它与业务层有什么不同,因为从我读过的内容看起来非常相似?如果它在第一个需要的话?我们所要做的就是以最佳方式构建我们的应用程序您对它的想法和经验是什么?
architecture business-logic-layer service-layer asp.net-mvc-2
考虑到这一点:
[Flags]
public enum MyEnum {
One = 1,
Two = 2,
Four = 4,
Eight = 8
}
public static class FlagsHelper
{
public static bool Contains(this MyEnum keys, MyEnum flag)
{
return (keys & flag) != 0;
}
}
Run Code Online (Sandbox Code Playgroud)
是否有可能编写一个适用于任何产品的通用版本的Contains enum而不仅仅是MyEnum?
编辑:
在阅读完答案后,这将是我的版本:
public static bool Contains(this Enum keys, Enum flag)
{
ulong keysVal = Convert.ToUInt64(keys);
ulong flagVal = Convert.ToUInt64(flag);
return (keysVal & flagVal) == flagVal;
}
Run Code Online (Sandbox Code Playgroud)
刚刚意识到检查我正在检查(return (keys & flag) != 0;)的方式是一个坏主意,因为 …
我有两个共享相同空间的HTML元素 - 当一个可见时,另一个不应该是.但是,如果我只是将对方的可见性设置为"隐藏",它仍占据显示层次结构中的空间,而我希望它消失.我不想完全删除引用,因为我需要能够在这两个元素之间切换.有任何想法吗?
我想提出一个文件浏览器,会做两件事情:1)允许用户浏览和选择一个目录2)允许用户浏览他们的SD卡中的所有文件
我找了教程,但似乎找不到?有人可以通过解释我的代码需要做什么才能拥有一个简单的文件浏览器或者为我提供教程/源代码的链接来帮助我吗?
拜托,谢谢!
上周,我用我的"小"rails应用程序成功集成了twitter.如果我在我的rails应用程序中创建一个新记录,它将发布在twitter上.
但是我如何用Facebook做到这一点?Twitter真的很容易(感谢Twitter的宝石)你能推荐一个宝石吗?指向示例应用程序的链接也很不错.
在此先感谢欢呼tabaluga
ps哦,我忘了提,我没有个人的facebook账号.Facebook Wall是一个公司网站.
作品
<a href="@Url.Action("edit", "markets", new { id = 1 })"
data-rel="dialog" data-transition="pop" data-icon="gear" class="ui-btn-right">Edit</a>
Run Code Online (Sandbox Code Playgroud)
不工作 - 为什么?
@Html.ActionLink("Edit", "edit", "markets", new { id = 1 }, new {@class="ui-btn-right", data-icon="gear"})
Run Code Online (Sandbox Code Playgroud)
看来你不能把像data-icon ="gear"这样的东西传递给htmlAttributes?
建议?
我一直试图了解几个小时的事情,我想得到你的观点.
我在我的一个类属性上有setter/getter(我注意到我必须在setter名称前添加"set",否则编译器会说没有setter):
@property (nonatomic, retain, readwrite, setter=setTopString:, getter=TopString) NSString* m_topString;
Run Code Online (Sandbox Code Playgroud)
当我像这样调用setter时,编译器很高兴:
[secureKeyboardController setTopString:@"This action requires that your enter your authentication code."];
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用"点"约定时,我被编译器拒绝了:
secureKeyboardController.topString = @"This action requires that your enter your authentication code.";
Run Code Online (Sandbox Code Playgroud)
真正奇怪的是点命名约定适用于此属性:
@property (nonatomic, readwrite, getter=PINMaxLength, setter=setPINMaxLength:) NSInteger m_PINMaxLength;
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我可以做:
[secureKeyboardController setPINMaxLength:10];enter code here
Run Code Online (Sandbox Code Playgroud)
要么
secureKeyboardController.PINMaxLength = 10;
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,编译器都很高兴.
我真的想睡得比我现在感觉的那么愚蠢.因此,我们将非常感谢任何解释.
此致,Apple92
我有一个列表列表,并想检查它是否已包含具有特定项目的列表.
从这个例子中应该清楚一切:
list = [[1,2],[3,4],[4,5],[6,7]]
for test in [[1,1],[1,2],[2,1]]:
if test in list:
print True
else:
print False
#Expected:
# False
# True
# True
#Reality:
# False
# True
# False
Run Code Online (Sandbox Code Playgroud)
是否有一个函数可以比较列表中的项目,无论它们如何排序?
我想使用Jon Skeet的SmartEnumerable来循环,Regex.Matches但它不起作用.
foreach (var entry in Regex.Matches("one :two", @"(?<!\w):(\w+)").AsSmartEnumerable())
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下为什么吗?并提出一个解决方案,使其工作.谢谢.
错误是:
'System.Text.RegularExpressions.MatchCollection' does not contain a definition
for 'AsSmartEnumerable' and no extension method 'AsSmartEnumerable' accepting
a first argument of type 'System.Text.RegularExpressions.MatchCollection' could
be found (are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud) 我想创建一个非常通用的实用程序方法来获取任何Collection并将其转换为从Number(Long,Double,Float,Integer等)扩展的用户可选类的集合.
我想出了这个代码,它使用Google Collections来转换Collection并返回一个Immutable List.
import java.util.List;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
/**
* Takes a {@code List<String>} and transforms it into a list of the
* specified {@code clazz}.
*
* @param <T>
* @param stringValues
* the list of Strings to be used to create the list of the
* specified type
* @param clazz
* must be a subclass of Number. Defines the type of the new List
* @return
*/
public static <T extends Number> List<T> …Run Code Online (Sandbox Code Playgroud) c# ×2
actionlink ×1
android ×1
architecture ×1
asp.net-mvc ×1
browser ×1
collections ×1
enums ×1
facebook ×1
file ×1
generics ×1
getter ×1
guava ×1
html ×1
ienumerable ×1
java ×1
javascript ×1
layout ×1
list ×1
objective-c ×1
python ×1
regex ×1
setter ×1
sorting ×1
visibility ×1