Exemplo n.º 1
0
 public static AutomobileFactory Getinstance()
 {
     if (_container == null)
     {
         _container = new AutomobileFactory();
     }
     return(_container);
 }
Exemplo n.º 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();
        }