Beispiel #1
0
        private static void SingletonPatternDemo()
        {
            SerialNumberGenerator generator = SerialNumberGenerator.Instance;

            Console.WriteLine("next serial " + generator.NextSerial);
            Console.WriteLine("next serial " + SerialNumberGenerator.Instance.NextSerial);
            Console.WriteLine("next serial " + generator.NextSerial);
        }
Beispiel #2
0
        private static void SingletonPatternDemo()
        {
            SerialNumberGenerator generator = SerialNumberGenerator.Instance;

            Console.WriteLine("next serial" + generator.NextSerial);                      //either one of these is the proper way of calling
            Console.WriteLine("next serial" + SerialNumberGenerator.Instance.NextSerial); //either one of these is the proper way of calling
            Console.WriteLine("next serial" + generator.NextSerial);                      //either one of these is the proper way of calling
        }
Beispiel #3
0
        static void SingletonDemo()
        {
            SerialNumberGenerator generator = SerialNumberGenerator.Instance;

            Console.WriteLine("next serial: {0}", generator.NextSerial());
            Console.WriteLine("next serial: {0}", generator.NextOtherSerial);
            Console.WriteLine("next serial: {0}", generator.NextSerial());
            Console.WriteLine("next serial: {0}", generator.NextOtherSerial);
        }
        //Singleton Design Pattern Demo Method
        private static void SingletonPatternDemo()
        {
            /*Object instance of SerialNumberGenerator is created and is assigned an instance.
            * This instance either returns an existing one or creates a new one in its class*/

            SerialNumberGenerator generator = SerialNumberGenerator.Instance;

            //You need the above line to use the below line

            //Print out the serial numbers to the console
            Console.WriteLine("Next serial " + generator.NextSerial);
            //Above and below do same thing, just different ways to type it - but Sr. Dev would probably say to use below
            Console.WriteLine("Next serial " + SerialNumberGenerator.Instance.NextSerial);//this combines above 2 lines into 1
            Console.WriteLine("Next serial " + generator.NextSerial);
        }
Beispiel #5
0
        public void AllocateBikerSerial()
        {
            SerialNumberGenerator serial = SerialNumberGenerator.Instance;

            Console.WriteLine("Allocating Bike number {0}", serial.NextOtherSerial);
        }