Ejemplo n.º 1
0
        static public void Run()
        {
            Console.WriteLine("------------LazySingleton------------");
            WorldCreator.Instance("Mario World");
            WorldCreator.Instance().Create();

            //The world name don't be changed
            WorldCreator.Instance("Yoshi's World");
            WorldCreator.Instance().Create();
        }
Ejemplo n.º 2
0
        static public void Run()
        {
            Console.WriteLine("------------Singleton------------");
            //Two way for use Singleton
            //1
            WorldCreator worldCreator = WorldCreator.Instance("Mario World");

            worldCreator.Create();
            //2
            WorldCreator.Instance("Mario World");
            WorldCreator.Instance().Create();

            //The world name don't be changed
            worldCreator = WorldCreator.Instance("Yoshi's World");
            worldCreator.Create();
        }