如何重新启动Java AWT应用程序?我有一个按钮,我附加了一个事件处理程序.我应该使用什么代码来重启应用程序?
我想做与Application.Restart()C#应用程序相同的事情.
如何Services和Repositories在DDD的相互关系?我的意思是,在过去的两天里,我一直在阅读DDD,无论我走到哪里,总会有Service一层,而且总有Repository一层.这些如何区分或互相恭维?
从我所读到的,不是Repository负责委托应用程序和数据之间的交互的层?
那么,Service如果层必须实现Repository与数据交互,那么对层的需求是什么,即使Repository可能已经实现了所需的方法?
我很欣赏这个主题的一些启示.
PS不知道这是否有用,但我正在使用ASP.NET MVC 2应用程序,我正在尝试实现Repository模式.我刚刚完成了依赖注入模式的实现(有史以来第一次)......
UPDATE
好的,有这么多答案,我想我明白了它的不同之处.所以,审查(纠正我,如果我错了):
阿Repository层只与单个对象从数据库或ORM的相互作用,IEmployeeRepository- > Employee.
阿Service层封装上从返回的对象更复杂的功能Repositories,无论是一个或多个.
那么,我有一个子问题.创建要发送到我的视图的抽象对象被认为是不好的做法吗?例如一个AEmployee(A对于abstract因为对我来说I意味着interface),其含有从性能Employee和X或X?
实际上,还有一个问题.如果一个Service层可以被认为是"调整"的应用程序,它是否需要通过接口实现?
我知道有很多关于salting密码的博客,文章和问题,但有一点我无法找到答案是:
如果我生成这样的密码哈希:
$salt = randomString
$password = $_POST['password']
hashedPassword = sha1($password.$salt)
Run Code Online (Sandbox Code Playgroud)
我有一张这样的桌子:
Users
user_id | hashedPassword | salt
Run Code Online (Sandbox Code Playgroud)
为什么攻击者难以识别此密码?难道他们不能只使用彩虹表,或蛮力来弄清楚盐,然后将盐附加到字典攻击中的每个单词?
A部分:
我知道有很多东西告诉你浏览器是否支持某个HTML5属性,例如http://diveintohtml5.info/detect.html,但他们没有告诉你如何从个人获取类型元素并使用该信息来初始化您的插件.
所以我尝试过:
alert($("input:date"));
//returns "[object Object]"
alert($("input[type='date']"));
//returns "[object Object]"
alert($("input").attr("type"));
//returns "text" ... which is a lie. it should have been "date"
Run Code Online (Sandbox Code Playgroud)
没有人工作.
我最终想出了这个(确实有效):
var inputAttr = $('<div>').append($(this).clone()).remove().html().toLowerCase();
alert(inputAttr);
// returns "<input min="-365" max="365" type="date">"
Run Code Online (Sandbox Code Playgroud)
谢谢:http://jquery-howto.blogspot.com/2009/02/how-to-get-full-html-string-including.html
所以我的第一个问题:1.为什么我不能在不支持html5的浏览器中读取"type"属性?您可以组成任何其他属性和伪造值并阅读它.2.为什么我的解决方案有效?为什么它在DOM中是否重要?
B部分:
以下是我使用探测器的基本示例:
<script type="text/javascript" >
$(function () {
var tM = document.createElement("input");
tM.setAttribute("type", "date");
if (tM.type == "text") {
alert("No date type support on a browser level. Start adding date, week, month, and time …Run Code Online (Sandbox Code Playgroud) 我通过COM连接到某个程序并接收System .__ ComObject.我知道它的几种方法,所以我可以这样做:
object result = obj.GetType().InvokeMember("SomeMethod", BindingFlags.InvokeMethod, null, obj, new object[] { "Some string" });
Run Code Online (Sandbox Code Playgroud)
并且喜欢这个
dynamic dyn = obj;
dyn.SomeMethod("Some string");
Run Code Online (Sandbox Code Playgroud)
两种方法都很好.但是如何确定com对象的内部类型信息并通过其所有成员进行枚举?
我试过这个:
[ComImport, Guid("00020400-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDispatch
{
void Reserved();
[PreserveSig]
int GetTypeInfo(uint nInfo, int lcid, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(TypeToTypeInfoMarshaler))] out System.Type typeInfo);
}
...
IDispatch disp = (IDispatch)obj;
Type t;
disp.GetTypeInfo(0, 0, out t);
Run Code Online (Sandbox Code Playgroud)
但是t最后是空的.谁能帮我?
我正在进行有关使用GET请求的编程任务.我在用C.
我想知道GET包的任何头字段和值是否必须大写?
例如:
GET / HTTP/1.1
Connection: Keep-Alive
Run Code Online (Sandbox Code Playgroud)
VS
get / HTTP/1.1
connection: keep-alive
Run Code Online (Sandbox Code Playgroud) 我有一个WPF应用程序 - 一个XBAP - 在主页面上有一个ComboBox.当我在ComboBox中选择一个项目时,事件处理程序会重建一个集合,该集合是列表框的数据源.看起来很简单,我之前在WPF中所做的所有事情.
这是从列表中选择项目后我的下拉列表的样子:

红色边界来自哪里?我正在从头开始构建表单,现在没有任何样式或任何内容.项目中的任何地方都没有提到"红色"字样.一旦它出现它就不会消失,并且它出现在我置于控件之上的任何东西上.
这是标记:
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource ResourceKey=DeviceInfoNameConverter}}"></TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)
更多细节:
我对搜索到目前为止唯一的猜测是,某种默认错误模板正在应用于控件.我正在使用WIA,VS输出窗口中出现了几个COM异常,显然与ListView的数据绑定有关.控件的数据源是WIA.DeviceInfo对象,转换器只是获取下拉文本的name属性.
说我有一个表与这些列的评论:Id,Comment,Category,CreatedDate,CommenterId
我想从评论表中获取前5个类别(基于该表中每个类别的计数).我如何在linq中执行此操作,以返回List或IQueryable?
为什么:
<Trigger Property="ItemsControl.AlternationIndex" Value="2">
<Setter Property="Background" Value="#FAC896"></Setter>
</Trigger>
Run Code Online (Sandbox Code Playgroud)
并不是:
<Trigger Property="ItemsControl.AlternationIndex" Value="2">
<Setter Property="Background" Value="50 50 50 255"></Setter>
</Trigger>
Run Code Online (Sandbox Code Playgroud)
?
这是出于Xaml解析器/编译器的性能原因吗?
我问的原因是,艺术家在使用RGB和/或HSV颜色时很难设计界面.
顺便说一句,我使用VS 2010 WPF编辑器.