public PrinterManager(ILog logger) { _logger = logger; BeforePrint = new PrinterDelegate(_logger.Log); OnPrinted = new PrinterDelegate(_logger.Log); Printers = new List <IPrinter>(); }
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(); }
static PrinterManager() { Printers = new List <Printer> { new CanonPrinter(), new EpsonPrinter() }; logger = Log; }
public Timer(PrinterDelegate deleg, int timeInterval, int?totalCalls) { this.Delegate = deleg; this.TotalCalls = totalCalls; this.TimeInterval = timeInterval; }
// Constructor public Timer(PrinterDelegate deleg, int timeInterval) : this(deleg, timeInterval, null) { }
public Timer(PrinterDelegate deleg, int timeInterval, int? totalCalls) { this.Delegate = deleg; this.TotalCalls = totalCalls; this.TimeInterval = timeInterval; }