public PrinterManager(ILog logger)
 {
     _logger     = logger;
     BeforePrint = new PrinterDelegate(_logger.Log);
     OnPrinted   = new PrinterDelegate(_logger.Log);
     Printers    = new List <IPrinter>();
 }
Пример #2
0
 static void Main()
 {
     Console.WriteLine("This program tests the Timer class that takes two arguments in its first contructor - a delegate and an integer number that represents a time interval in seconds. An instance method is then executed which calls the delegate, passed as a parameter each s seconds. Another constructor allows the user to set the number of calls.");
     Console.WriteLine("The test Timer instance will run 3 times on 5 seconds interval between each. It will call a delegate which contains 2 methods - one that prints the current date and time and another that prints a random number.");
     Console.WriteLine();
     PrinterDelegate d = new PrinterDelegate(PrintDateTime);
     d += PrintRandomNumber;
     Timer t = new Timer(d, 5, 4);
     t.RunTimer();
 }
Пример #3
0
        static PrinterManager()
        {
            Printers = new List <Printer>
            {
                new CanonPrinter(),
                new EpsonPrinter()
            };

            logger = Log;
        }
Пример #4
0
    static void Main()
    {
        Console.WriteLine("This program tests the Timer class that takes two arguments in its first contructor - a delegate and an integer number that represents a time interval in seconds. An instance method is then executed which calls the delegate, passed as a parameter each s seconds. Another constructor allows the user to set the number of calls.");
        Console.WriteLine("The test Timer instance will run 3 times on 5 seconds interval between each. It will call a delegate which contains 2 methods - one that prints the current date and time and another that prints a random number.");
        Console.WriteLine();
        PrinterDelegate d = new PrinterDelegate(PrintDateTime);

        d += PrintRandomNumber;
        Timer t = new Timer(d, 5, 4);

        t.RunTimer();
    }
Пример #5
0
 public Timer(PrinterDelegate deleg, int timeInterval, int?totalCalls)
 {
     this.Delegate     = deleg;
     this.TotalCalls   = totalCalls;
     this.TimeInterval = timeInterval;
 }
Пример #6
0
 // Constructor
 public Timer(PrinterDelegate deleg, int timeInterval)
     : this(deleg, timeInterval, null)
 {
 }
Пример #7
0
 public Timer(PrinterDelegate deleg, int timeInterval, int? totalCalls)
 {
     this.Delegate = deleg;
     this.TotalCalls = totalCalls;
     this.TimeInterval = timeInterval;
 }
Пример #8
0
 // Constructor
 public Timer(PrinterDelegate deleg, int timeInterval)
     : this(deleg, timeInterval, null)
 {
 }