摘要: 单例模式 线程检查: public sealed class PreThreadSingleton { private static ThreadLocal<PreThreadSingleton> local = new ThreadLocal<PreThreadSingleton>(() => n 阅读全文
posted @ 2022-05-12 17:44 后跳 阅读(35) 评论(0) 推荐(0)
摘要: 单例模式 LAZY<T>: interface IDatabase { int GetConnection(string name); } class FileDatabase : IDatabase { private Dictionary<string, int> dic = new Dicti 阅读全文
posted @ 2022-05-12 17:40 后跳 阅读(71) 评论(0) 推荐(0)
摘要: 单例模式 MonoState public class Boss { private static string name; public string Name { get => name; set => name = value; } public override string ToStrin 阅读全文
posted @ 2022-05-12 17:35 后跳 阅读(17) 评论(0) 推荐(0)
摘要: 单例模式:上下文语境 using System; using System.Collections.Generic; namespace DesignParttern_Singleton_Context { public class BuildContext:IDisposable { public 阅读全文
posted @ 2022-05-12 17:26 后跳 阅读(46) 评论(0) 推荐(0)