static void Main(string[] args)
        {
            Singleton fromEmployee = Singleton.GetInstance;

            fromEmployee.PrintDetails("This is the first message");

            Singleton fromStudent = Singleton.GetInstance;

            fromStudent.PrintDetails("This is the second message");

            Console.WriteLine("----------------------------------------------");

            // If Singleton wouldn't be sealed
            //Singleton.NestedDerivedSingleton derivedObj = new Singleton.NestedDerivedSingleton();
            //derivedObj.PrintDetails("From nested derived class");

            //Output:
            //    Counter value: 1
            //    This is the first message
            //    This is the second message
            //    ----------------------------------------------
            //    Counter value: 2
            //    From nested derived class

            Console.ReadLine();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Singleton fromEmployee = Singleton.GetInstance;

            fromEmployee.PrintDetails("From Employee");

            Singleton fromStudent = Singleton.GetInstance;

            fromEmployee.PrintDetails("From Student");

            Console.WriteLine("-------------------------------");

            //Singleton.DerivedSingleton derivedObj = new Singleton.DerivedSingleton();
            //derivedObj.PrintDetails("From Derived");

            Console.ReadLine();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: pmsagar/DesignPatterns
        static void Main(string[] args)
        {
            Singleton s1 = Singleton.GetInstance;

            s1.PrintDetails("This is first message.");
            Singleton s2 = Singleton.GetInstance;

            s2.PrintDetails("This is second message.");
        }
コード例 #4
0
        static void Main(string[] args)
        {
            Singleton fromTeachaer = Singleton.GetInstance;

            fromTeachaer.PrintDetails("Del porefesor");
            Singleton fromStudent = Singleton.GetInstance;

            fromStudent.PrintDetails("Del estudiante");
            Console.ReadLine();
        }
コード例 #5
0
        private static void PrintStudentdetails()
        {
            /*
             * Assuming Singleton is created from student class
             * we refer to the GetInstance property from the Singleton class
             */
            Singleton fromStudent = Singleton.GetInstance;

            fromStudent.PrintDetails("From Student");
        }
コード例 #6
0
        private static void PrintEmployeeDetails()
        {
            /*
             * Assuming Singleton is created from employee class
             * we refer to the GetInstance property from the Singleton class
             */
            Singleton fromEmployee = Singleton.GetInstance;

            fromEmployee.PrintDetails("From Employee");
        }
        static void Main(string[] args)
        {
            Singleton fromEmployee = Singleton.GetInstance;

            fromEmployee.PrintDetails("This is the first message");

            Singleton fromStudent = Singleton.GetInstance;

            fromStudent.PrintDetails("This is the second message");

            Console.ReadLine();
        }
コード例 #8
0
        static void Main(string[] args)
        {
            Singleton fromTeacher = Singleton.GetInstance;

            fromTeacher.PrintDetails("From teacher");

            Singleton fromEstudent = Singleton.GetInstance;

            fromEstudent.PrintDetails("From student");

            Console.ReadLine();
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: luisp033/DesignPatterns
        static void Main(string[] args)
        {
            Singleton fromEmployee = Singleton.GetInstance;

            fromEmployee.PrintDetails("From Employee");

            Singleton fromStudent = Singleton.GetInstance;

            fromStudent.PrintDetails("From Student");


            Console.ReadLine();
        }
コード例 #10
0
        static void Main(string[] args)
        {
            Singleton fromemployee = Singleton.GetInstance;

            fromemployee.PrintDetails("from employee");

            Singleton fromStudent = Singleton.GetInstance;

            fromStudent.PrintDetails("from student");

            //Singleton.DerivedSingleton ds = new SingletonDemo.Singleton.DerivedSingleton();
            //ds.PrintDetails("from derived class");

            Console.ReadLine();
        }
コード例 #11
0
        static void Main(string[] args)
        {
            /*
             * Assuming Singleton is created from employee class
             * we refer to the GetInstance property from the Singleton class
             */
            Singleton fromEmployee = Singleton.GetInstance;

            fromEmployee.PrintDetails("From Employee");

            /*
             * Assuming Singleton is created from student class
             * we refer to the GetInstance property from the Singleton class
             */
            Singleton fromStudent = Singleton.GetInstance;

            fromStudent.PrintDetails("From Student");

            Console.ReadLine();
        }
コード例 #12
0
        private static void PrintStudentDetails()
        {
            Singleton singleton = Singleton.GetInstance;

            singleton.PrintDetails("From Student Class");
        }
コード例 #13
0
        private static void PrintDetails1()
        {
            Singleton s1 = Singleton.GetInstance;

            s1.PrintDetails("This is first message from S1");
        }
コード例 #14
0
        private static void PrintEmployeeDetails()
        {
            Singleton p = Singleton.GetInstance;

            p.PrintDetails("hi");
        }
コード例 #15
0
        private static void PrintDetails2()
        {
            Singleton s2 = Singleton.GetInstance;

            s2.PrintDetails("This is second message from S2");
        }
コード例 #16
0
        private static void PrintStudentDetails()
        {
            Singleton s = Singleton.GetInstance;

            s.PrintDetails("hello");
        }
コード例 #17
0
        private static void PrintStudentDetails()
        {
            Singleton fromStudent = Singleton.GetInstance;

            fromStudent.PrintDetails("From Student object is getting created.");
        }
コード例 #18
0
        private static void PrintEmployeeDetails()
        {
            Singleton singleton2 = Singleton.GetInstance;

            singleton2.PrintDetails("From Employee Class");
        }
コード例 #19
0
        private static void PrintEmployeeDetails()
        {
            Singleton fromEmployee = Singleton.GetInstance;

            fromEmployee.PrintDetails("From Employee");
        }
コード例 #20
0
        private static void PrintTeacherDetails()
        {
            Singleton fromTeacher = Singleton.GetInstance;

            fromTeacher.PrintDetails("From Teacher");
        }
コード例 #21
0
        private static void PrintStudentDetails()
        {
            Singleton fromStudent = Singleton.GetInstance;

            fromStudent.PrintDetails("From Student");
        }
コード例 #22
0
        private static void PrintTeacherDetails()
        {
            Singleton fromTeacher = Singleton.GetInstance;

            fromTeacher.PrintDetails("From Teacher object is getting created.");
        }