在我的系统中,我有两个不同的项目,一个定义其接口,另一个定义其域对象.到目前为止,我设法使接口定义独立于域对象,但我现在感觉需要将某些域对象作为接口中定义的方法的参数或作为返回值.
我应该抵制并尝试保持接口独立于域对象,还是这是一个毫无根据的问题?
编辑 - 在发布问题之后,我考虑为每个域对象定义一个接口,这样他们可以保持分离 - 不知道它是否过度或者是否是要支付的价格,所以它们保持独立.
编辑#2 - 我被要求举一个例子,所以我会尽量保持简单.我有一个处理图像转换的过程,我的一个域对象是一个包含分辨率,页面列表,哈希等信息的类.让它称为DocumentInfo.我有一个使用DocumentInfo来执行GeneratePdfFromTiff等操作的类; 我首先将GeneratePdfFromTiff定义为IImageHandler的接口方法,然后由ImageHandler实现.
问题是 - GeneratePdfFromTiff的参数之一是DocumentInfo.这里我在接口级别定义的方法必须知道在域级别定义的DocumentInfo.这是我所关注的那种依赖.
你知道任何提供死锁恢复的ORM工具吗?我知道死锁是一件坏事,但有时任何系统都会受到负载的影响.在Sql Server中,死锁消息显示"重新运行事务",因此我怀疑重新运行死锁语句是ORM的理想功能.
public class A
{
private string _a_string;
public string AString
{
get { return _a_string; }
set { _a_string = value; }
}
}
public class B
{
private string _b_string;
private A _a;
public A A
{
get { return _a; }
set { _a = value; }
}
public string BString
{
get { return _b_string; }
set { _b_string = value; }
}
}
Run Code Online (Sandbox Code Playgroud)
这不起作用:
B _b = new B { A = { AString = "aString" …Run Code Online (Sandbox Code Playgroud) 导航发生时(OnBeforeNavigate)和完成(OnDocumentComplete)时,很容易知道使用IWebBrowser2接口.但是,浏览器中的许多工作都是通过Ajax调用(使用XMLHttpRequest)完成的.
有没有办法在Ajax调用发生并在IE中完成时订阅事件跟踪?
这是我的第一个StackOverflow问题,所以要好!:-)
我最近在一些C#源代码中遇到了以下示例:
public IFoo GetFooInstance()
{
#IF DEBUG
return new TestFoo();
#ELSE
return new Foo();
#ENDIF
}
Run Code Online (Sandbox Code Playgroud)
这引出了我这些问题:
有谁知道一个好的TWAIN浏览器插件来扫描图像并发送到Web应用程序?如果它包含诸如去偏移等功能,那就更好了.谢谢!
我们在工作中有相当多的可重用代码(一件好事).每当我创建一个使用它们的新项目时,我习惯将他们的项目作为我的解决方案的一部分包含在内,我想知道是否应该将它们重新用作已发布的dll.我包含该项目的原因(或理由)是,如果我发现其中一个错误,我可以在那里进行分支和修复.但它似乎将我的重点放在手头的项目上.
(不确定这是否应该是CW,因为只有两个答案,我有兴趣了解您的偏好)
我知道BackgroundWorker不应该在Windows服务中使用,但是有人会有一个很好的在线参考解释原因吗?
根据微软的样本,以下是如何通过WCF流式传输文件:
// Service class which implements the service contract
public class StreamingService : IStreamingSample
{
public System.IO.Stream GetStream(string data)
{
//this file path assumes the image is in
// the Service folder and the service is executing
// in service/bin
string filePath = Path.Combine(
System.Environment.CurrentDirectory,
".\\image.jpg");
//open the file, this could throw an exception
//(e.g. if the file is not found)
//having includeExceptionDetailInFaults="True" in config
// would cause this exception to be returned to the client
try
{
FileStream imageFile …Run Code Online (Sandbox Code Playgroud)