Пример #1
0
        public static SingletonTest GetInstance(string name)
        {
            if (lookupDictionary.TryGetValue(name, out _instance))
            {
                return(_instance);
            }

            if ("SingletonSubClass".Equals(name))
            {
                _instance = new SingletonSubClass();
            }

            if ("SingletonSubClass2".Equals(name))
            {
                _instance = new SingletonSubClass2();
            }


            return(_instance);
        }
Пример #2
0
 public SingletonSubClass2()
 {
     SingletonTest.Register("SingletonSubClass2", this);
 }
Пример #3
0
 public static void Register(string name, SingletonTest st)
 {
     lookupDictionary.Add(name, st);
 }