Exemple #1
0
        public void TestCreateSingletonLazy()
        {
            SingletonLazy s1 = SingletonLazy.Instance;
            SingletonLazy s2 = SingletonLazy.Instance;

            Assert.Same(s1, s2);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            SingletonLazy ss = SingletonLazy.Instance;

            var ss2 = SingletonLazy.Instance;

            Console.WriteLine(ss);
            Console.WriteLine(ss2);

            Console.WriteLine("Hello World!");
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Singleton singleton = Singleton.UniqueInstance;

            singleton.Log("Initialize");

            SingletonLazy singletonLazy = SingletonLazy.UniqueInstance;

            singletonLazy.Log("Lazy Initialize");

            Console.ReadLine();
        }
Exemple #4
0
 static SingletonCreator()
 {
     uniqueInstance = new SingletonLazy();
 }