PluginCore.cs 1007 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.IO;
  3. using MeidoPhotoStudio.Converter.Converters;
  4. namespace MeidoPhotoStudio.Converter
  5. {
  6. public class PluginCore
  7. {
  8. private readonly IConverter[] converters;
  9. public string WorkingDirectory { get; set; }
  10. public PluginCore(string workingDirectory, params IConverter[] converters)
  11. {
  12. WorkingDirectory = workingDirectory;
  13. this.converters = converters;
  14. }
  15. public void Convert()
  16. {
  17. Directory.CreateDirectory(WorkingDirectory);
  18. foreach (var converter in converters)
  19. {
  20. try
  21. {
  22. converter.Convert(WorkingDirectory);
  23. }
  24. catch (Exception e)
  25. {
  26. if (Plugin.Instance == null)
  27. continue;
  28. Plugin.Instance.Logger.LogError($"Could not convert data because {e}");
  29. }
  30. }
  31. }
  32. }
  33. }