在标签之间切换时,我的验证错误正在消失.
我如何阻止这种情况发生?
鉴于此接口
public interface IMyInterface
{
string Method1();
}
Run Code Online (Sandbox Code Playgroud)
为什么这是有效的
public sealed class InheretedFromInterfaceSealed: IMyInterface
{
public string Method1()
{
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
但这不是
public class InheretedFromInterfaceWithSomeSealed: IMyInterface
{
public sealed string Method1()
{
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
然而,它是抽象类的有效场景
public abstract class AbstractClass
{
public abstract string Method1();
}
public class InheretedFromAbstractWithSomeSealed: AbstractClass
{
public sealed override string Method1()
{
return null;
}
}
Run Code Online (Sandbox Code Playgroud) 假设我们有两个业务组件
这拥有用户.更改用户信息时,此组件将发布消息.所以例如"NewUserCreated"
处理与用户的通信.电子邮件,推文等.因此,该组件订阅用户消息将该信息的子集存储在其自己的商店中.
如果用户管理组件在出版物组件之前联机,会发生什么?出版物如何获得现有用户列表?它不应该知道用户管理组件如何存储其数据.
在为属性执行支持字段时,常见的命名方案是什么?
编辑:提出特定于.net的问题
我想在下面的代码的空catch块中测试一些异常处理逻辑.
try
{
//Do Some stuff that throws a exception
//This is the code i need
}
catch (Exception)
{
//Handle things that inherits from Exception
}
catch
{
//Handle things that dont inherits from Exception
//Want to test this code
}
Run Code Online (Sandbox Code Playgroud) 我想在UNC路径中创建一个空文件夹,并将所有文件从本地磁盘复制到该特定的空文件夹.我试过,WDEngine.UploadFile但它似乎只适用于本地磁盘.File.copy在复制所有文件时工作正常但唯一的问题在于如何在UNC路径中创建一个空文件夹以粘贴从本地磁盘复制的所有文件.
感谢您的回复,谢谢!
我试图检测用户在关闭程序之前是否保存了他们的工作。我尝试过以下编码:
void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
MessageBox.Show("Unsave Work");
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用。当我关闭程序时什么也没有发生。
我有一个有趣的用例,其中某些异常类型意味着"此消息不再有效且应该被忽略"但是此代码没有任何意识,Bus以便调用Bus.DoNotContinueDispatchingCurrentMessageToHandlers().
我讨厌像每个消息处理程序中都需要的try/catch块这样的样板代码.所以我开始实现一个UnitOfWork来处理和吞下异常,但我找不到告诉框架的方法"是的,这个代码生成了一个异常,但忘记了这一点,只是完成了事务."
Bus.DoNotContinueDispatchingCurrentMessageToHandlers()不起作用.我尝试过ITransport注入和调用,AbortHandlingCurrentMessage()但这导致整个宇宙爆炸.即使单步执行源代码,我似乎也不知所措.
请注意,很可能这是一个可怕的想法,因为假设实际上存在异常情况时没有异常将导致事务提交,从而导致谁知道有多少不良的未知副作用.因此,最好有一个方法仍然回滚事务但丢弃该消息.但我会对潜在的"是的我知道我在做什么,提交交易而不管异常"选项感兴趣.
.net ×6
c# ×2
nservicebus ×2
binding ×1
event-store ×1
exception ×1
field ×1
inheritance ×1
interface ×1
messaging ×1
properties ×1
sealed ×1
unit-of-work ×1
validation ×1
virtual ×1
winforms ×1
wpf ×1
xaml ×1