Exemple #1
0
        private static void SingletonPatternDemo()
        {
            SerialNumberGeneratorGadgetSmall generatorGadgetSmall = SerialNumberGeneratorGadgetSmall.Instance;

            Console.WriteLine("gadget small next serial number: " + generatorGadgetSmall.NextSerial);

            SerialNumberGeneratorGadgetMedium generatorGadgetMedium = SerialNumberGeneratorGadgetMedium.Instance;

            Console.WriteLine("gadget medium next serial number: " + generatorGadgetMedium.NextSerial);

            SerialNumberGeneratorGadgetLarge generatorGadgetLarge = SerialNumberGeneratorGadgetLarge.Instance;

            Console.WriteLine("gadget large next serial number: " + generatorGadgetLarge.NextSerial);

            SerialNumberGeneratorWidgetSmall generatorWidgetSmall = SerialNumberGeneratorWidgetSmall.Instance;

            Console.WriteLine("widget small next serial number: " + generatorWidgetSmall.NextSerial);

            SerialNumberGeneratorWidgetMedium generatorWidgetMedium = SerialNumberGeneratorWidgetMedium.Instance;

            Console.WriteLine("widget medium next serial number: " + generatorWidgetMedium.NextSerial);

            SerialNumberGeneratorWidgetLarge generatorWidgetLarge = SerialNumberGeneratorWidgetLarge.Instance;

            Console.WriteLine("widget large next serial number: " + generatorWidgetLarge.NextSerial);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            SerialNumberGeneratorGadgetSmall generatorGadgetSmall = SerialNumberGeneratorGadgetSmall.Instance;

            Console.WriteLine("gadget small next serial number: " + generatorGadgetSmall.NextSerial);

            SerialNumberGeneratorGadgetMedium generatorGadgetMedium = SerialNumberGeneratorGadgetMedium.Instance;

            Console.WriteLine("gadget medium next serial number: " + generatorGadgetMedium.NextSerial);

            SerialNumberGeneratorGadgetLarge generatorGadgetLarge = SerialNumberGeneratorGadgetLarge.Instance;

            Console.WriteLine("gadget large next serial number: " + generatorGadgetLarge.NextSerial);

            SerialNumberGeneratorWidgetSmall generatorWidgetSmall = SerialNumberGeneratorWidgetSmall.Instance;

            Console.WriteLine("widget small next serial number: " + generatorWidgetSmall.NextSerial);

            SerialNumberGeneratorWidgetMedium generatorWidgetMedium = SerialNumberGeneratorWidgetMedium.Instance;

            Console.WriteLine("widget medium next serial number: " + generatorWidgetMedium.NextSerial);

            SerialNumberGeneratorWidgetLarge generatorWidgetLarge = SerialNumberGeneratorWidgetLarge.Instance;

            Console.WriteLine("widget large next serial number: " + generatorWidgetLarge.NextSerial);
        }