Windsor 和 asp.net MVC 单例竞争条件

发布于 2024-10-07 20:43:19 字数 361 浏览 0 评论 0原文

关于在 Windsor 中使用 Singleton 生活方式和 Asp.Net MVC 的快速问题。 如果以下课程被注册为单例,我认为我会出现竞争条件是否正确?

public class UserMapper : IMap
{
    public void Map(MyDto dto, MyDomain domain)
    {
      domain.Username = dto.Username;
      domain.Firstname = dto.Firstname;
      domain.Surname = dto.Surname;
      domain.Password = dto.Password;
    }
}

Quick question regarding the use of Singleton lifestyle in Windsor, and Asp.Net MVC.
If the following class is registered as a singleton am I correct in thinking that I will have a race condition?

public class UserMapper : IMap
{
    public void Map(MyDto dto, MyDomain domain)
    {
      domain.Username = dto.Username;
      domain.Firstname = dto.Firstname;
      domain.Surname = dto.Surname;
      domain.Password = dto.Password;
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

国际总奸 2024-10-14 20:43:19

您的 UserMapper 中没有任何数据 - Map 方法中的所有内容都依赖于为其提供的参数,使得该方法可重入,因此可以安全地作为单例使用。

Your UserMapper does not have any data in it - everything in the Map method relies on parameters given to it, making the method reentrant and thus safe to use as a singleton.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文