public async Task <string> CreateDumpAsync(string dumpLocation) { var dumpFileLocation = dumpLocation; if (string.IsNullOrEmpty(dumpFileLocation)) { dumpFileLocation = _reflectionProvider.GetRunningAssemblyPath(); } else { if (!_directoryProvider.DoesDirectoryExists(dumpLocation)) { try { _directoryProvider.CreateDirectory(dumpLocation); _consoleProvider.WriteLine($"{dumpLocation} doesn't exists."); _consoleProvider.WriteLine($"{dumpLocation} created."); } catch (IOException e) { _consoleProvider.WriteLine(e.ToString()); _consoleProvider.WriteLine($"{dumpLocation} cannot be created."); throw; } } } var exceptionLogs = (await _logRepository.GetAllAsync()).ToList(); var sb = new StringBuilder(); foreach (var exceptionLog in exceptionLogs) { sb.AppendLine($"{exceptionLog.Date} {exceptionLog.Message} {exceptionLog.Exception}"); } var uniqueFileName = string.Concat(GenerateUniqueText(), ".txt"); var filePath = _pathProvider.Combine(dumpFileLocation, uniqueFileName); _fileProvider.WriteAllText(filePath, sb.ToString()); _consoleProvider.WriteLine($"dump file created successfully - {filePath}"); return(filePath); }
private IEnumerable <TPluginService> LoadPlugins <TPluginService>() { string path = _pathProvider.Combine(_reflectionProvider.GetRunningAssemblyPath(), "Plugins"); if (!_directoryProvider.Exists(path)) { _directoryProvider.CreateDirectory(path); } var allAssemblies = new List <Assembly>(); foreach (string dll in _directoryProvider.GetFiles(path, "*.dll")) { allAssemblies.Add(_assemblyProvider.LoadFile(dll)); } var configuration = new ContainerConfiguration().WithAssemblies(allAssemblies); var container = configuration.CreateContainer(); var services = container.GetExports <TPluginService>(); return(services); }