public bool CanHandle(ITimeRetrievalService timeRetrievalService) { var currentTime = timeRetrievalService.Now(); var start = new TimeSpan(06, 0, 0); var end = new TimeSpan(12, 0, 0); return(currentTime >= start && currentTime <= end); }
public string Greeting(string name, ITimeRetrievalService timeRetrievalService) { if (_one.CanHandle(timeRetrievalService)) { return(_one.Greeting(name, timeRetrievalService)); } if (_two.CanHandle(timeRetrievalService)) { return(_two.Greeting(name, timeRetrievalService)); } throw new InvalidOperationException(); }
public bool CanHandle(ITimeRetrievalService timeRetrievalService) { var currentTime = timeRetrievalService.Now(); var start = new TimeSpan(22, 0, 0); var end = new TimeSpan(06, 0, 0); if (start < end) { return(start <= currentTime && currentTime <= end); } return(!(end < currentTime && currentTime < start)); }
public bool CanHandle(ITimeRetrievalService timeRetrievalService) => _one.CanHandle(timeRetrievalService) || _two.CanHandle(timeRetrievalService);
public string Greeting(string input, ITimeRetrievalService timeRetrievalService) => $"Good morning {input}";
public Greeter(ITimeRetrievalService timeRetrievalService, ILogger logger) { _timeRetrievalService = timeRetrievalService; _logger = logger; }
public bool CanHandle(ITimeRetrievalService timeRetrievalService) => true;
public string Greeting(string input, ITimeRetrievalService timeRetrievalService) => $"Hello {input}";