小编Sim*_*mon的帖子

如何在选项卡之间移动时阻止WPF验证错误消失?

在标签之间切换时,我的验证错误正在消失.

我如何阻止这种情况发生?

.net validation wpf xaml binding

2
推荐指数
1
解决办法
453
查看次数

为什么我可以密封一个实现接口但不能封闭成员的类?

鉴于此接口

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)

.net virtual inheritance interface sealed

2
推荐指数
1
解决办法
914
查看次数

订阅者数据在发布者上线后播种

假设我们有两个业务组件

  1. 用户管理

这拥有用户.更改用户信息时,此组件将发布消息.所以例如"NewUserCreated"

  1. 出版物

处理与用户的通信.电子邮件,推文等.因此,该组件订阅用户消息将该信息的子集存储在其自己的商店中.

问题

如果用户管理组件在出版物组件之前联机,会发生什么?出版物如何获得现有用户列表?它不应该知道用户管理组件如何存储其数据.

messaging nservicebus distributed-computing event-store

2
推荐指数
1
解决办法
143
查看次数

.net中常见的"后备字段"命名方案是什么?

在为属性执行支持字段时,常见的命名方案是什么?

编辑:提出特定于.net的问题

.net field properties naming-conventions

1
推荐指数
1
解决办法
335
查看次数

结构相同如何与Int32一起使用?

当Int32没有实现相等运算符时,这是如何工作的?

 bool y = 6 == 5;
Run Code Online (Sandbox Code Playgroud)

.net c#

1
推荐指数
1
解决办法
73
查看次数

如何抛出不从Exception继承的异常?

我想在下面的代码的空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)

.net exception-handling exception

0
推荐指数
2
解决办法
256
查看次数

如何在.net中的UNC路径中创建空文件夹?

我想在UNC路径中创建一个空文件夹,并将所有文件从本地磁盘复制到该特定的空文件夹.我试过,WDEngine.UploadFile但它似乎只适用于本地磁盘.File.copy在复制所有文件时工作正常但唯一的问题在于如何在UNC路径中创建一个空文件夹以粘贴从本地磁盘复制的所有文件.

感谢您的回复,谢谢!

.net

0
推荐指数
1
解决办法
392
查看次数

程序关闭时 Form.FormClosing 不会被触发

我试图检测用户在关闭程序之前是否保存了他们的工作。我尝试过以下编码:

void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
    if (e.CloseReason == CloseReason.UserClosing)
        MessageBox.Show("Unsave Work");
}
Run Code Online (Sandbox Code Playgroud)

但这不起作用。当我关闭程序时什么也没有发生。

c# event-handling winforms

0
推荐指数
1
解决办法
5387
查看次数

NServiceBus UnitOfWork吞下某些异常并避免消息失败

我有一个有趣的用例,其中某些异常类型意味着"此消息不再有效且应该被忽略"但是此代码没有任何意识,Bus以便调用Bus.DoNotContinueDispatchingCurrentMessageToHandlers().

我讨厌像每个消息处理程序中都需要的try/catch块这样的样板代码.所以我开始实现一个UnitOfWork来处理和吞下异常,但我找不到告诉框架的方法"是的,这个代码生成了一个异常,但忘记了这一点,只是完成了事务."

Bus.DoNotContinueDispatchingCurrentMessageToHandlers()不起作用.我尝试过ITransport注入和调用,AbortHandlingCurrentMessage()但这导致整个宇宙爆炸.即使单步执行源代码,我似乎也不知所措.

请注意,很可能这是一个可怕的想法,因为假设实际上存在异常情况时没有异常将导致事务提交,从而导致谁知道有多少不良的未知副作用.因此,最好有一个方法仍然回滚事务但丢弃该消息.但我会对潜在的"是的我知道我在做什么,提交交易而不管异常"选项感兴趣.

nservicebus unit-of-work

0
推荐指数
1
解决办法
562
查看次数