Beispiel #1
0
 public static AutomobileFactory Getinstance()
 {
     if (_container == null)
     {
         _container = new AutomobileFactory();
     }
     return(_container);
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            //  AutomobileFactory factory = new AutomobileFactory();
            AutomobileFactory factory = AutomobileFactory.Getinstance(); //for singleton
            IAutoMobile       auto    = factory.Make(AutomobileFactory.AutoType.BMW);

            Console.WriteLine(auto.GetType());
            auto.Start();
            auto.Stop();
        }