コード例 #1
0
 private static void Add(PrinterFactory factory)
 {
     try
     {
         printerManager.Add(factory.CreatePrinter());
     }
     catch (Exception e)
     {
         System.Console.WriteLine(e);
         System.Console.ReadKey();
     }
 }
コード例 #2
0
        public void Add()
        {
            Console.WriteLine("\nEnter printer name");
            string name = Console.ReadLine();

            Console.WriteLine("Enter printer model");
            string model = Console.ReadLine();

            var printer = PrinterFactory.CreatePrinter(name, model);

            if (!this.repository.Contains(printer))
            {
                this.repository.Save(printer);
                Console.WriteLine("Printer added.");
            }
            else
            {
                Console.WriteLine("\nPrinter already exists.");
            }
        }
コード例 #3
0
 public void RegisterPrinterType(PrinterType printerType)
 {
     // Incase there are unprinted labels when changing printers.
     Labels.Clear();
     this.printer = PrinterFactory.CreatePrinter(printerType);
 }