public async Task RunAsync(string directoryPath, string outputFilePath) { if (!_directoryPathValidator.ValidateDirectoryPath(directoryPath)) { _notifier.NotifyUser($"The directory {directoryPath ?? "<null>"} is invalid or does not exist. Service shuts down."); return; } if (!_pathHelper.CanWrite(outputFilePath)) { _notifier.NotifyUser($"Cannot write on path {outputFilePath ?? "<null>"}. Service shuts down."); return; } var fullDirectoryPath = _pathHelper.GetFullPath(directoryPath); var fullOutputFilePath = _pathHelper.GetFullPath(outputFilePath); _notifier.NotifyUser($"Service started listening at {fullDirectoryPath}"); _peopleCache.Initialize(fullDirectoryPath); SerializeResults(_peopleAverageAgeEvaluator.ComputePeopleAverageAge(_peopleCache.GetPeople()), fullOutputFilePath); await InitializeDirectoryMonitorAsync(fullDirectoryPath, fullOutputFilePath); }