コード例 #1
0
        private void AddAndromeda()
        {
            //Nice I can get my instance here...
            var univer = Univer.Instance;

            Univer.AddGalaxies("Andromeda");
        }
コード例 #2
0
 //the private construtor
 private Univer()
 {
     //the check for unicity
     if (Instance == null)
     {
         Instance = new Univer();
     }
 }
コード例 #3
0
        private void AddMilkyWay()
        {
            //...And here !
            //It will be the same even if i'm not in the same project or solution...
            //Reminder do not mess the Univer in others projects, it could be painful to change...
            var univer = Univer.Instance;

            Univer.AddGalaxies("MilkyWay");
        }
コード例 #4
0
        public void Use_Pattern_Singleton_With_Design()
        {
            //Let talk about something bigger UNIVER !

            AddMilkyWay();
            AddAndromeda();

            var univer = Univer.Instance;

            Univer.ShowGalaxies();
        }