重新绑定Singleton C# [英] Rebind Singleton C#

查看:63
本文介绍了重新绑定Singleton C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个带有singleton的类库,如下所示

I have a class library with singleton as following

推荐答案

什么是"两个类别用于生产,一个用于测试"。意思?你可以改一下你的问题吗?

What does "two classes one for production and one for testing" mean? Can you rephrase your question?

参见Misko Hevery的演讲:
清洁代码会谈 - "全球国家和单身人士"

See Misko Hevery's talk: The Clean Code Talks - "Global State and Singletons"

顺便说一句,您的代码段不是Singleton模式的正确实现。这要求ctor是私有的。

Btw, your code snippet is not a proper implementation of the Singleton pattern. This requires that the ctor is private.


这篇关于重新绑定Singleton C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆