Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using MedsProcessor.Common;
  6. using MedsProcessor.Common.Models;
  7.  
  8. namespace MedsProcessor.WebAPI.Core
  9. {
  10. public class HzzoData
  11. {
  12. public HzzoData(AppPathsInfo appPaths)
  13. {
  14. this._appPaths = appPaths;
  15. }
  16.  
  17. private ISet<HzzoMedsDownloadDto> _set;
  18. private readonly AppPathsInfo _appPaths;
  19.  
  20. public ISet<HzzoMedsDownloadDto> Set
  21. {
  22. get => _set ??
  23. throw new InvalidOperationException("The dataset was not loaded.");
  24.  
  25. private set
  26. {
  27. if (_set != null)
  28. throw new InvalidOperationException("The dataset was already loaded.");
  29.  
  30. _set = value ??
  31. throw new InvalidOperationException("The loaded dataset can not be null.");
  32. }
  33. }
  34.  
  35. internal void Load(ISet<HzzoMedsDownloadDto> data) =>
  36. Set = data;
  37.  
  38. internal bool IsLoaded() =>
  39. _set != null && _set.All(x => x.IsDownloaded && x.IsDataParsed);
  40.  
  41. internal void Clear()
  42. {
  43. _set = null;
  44.  
  45. var downloadDir = Path.Combine(_appPaths.ApplicationRootPath, Constants.DOWNLOAD_DIR);
  46. Directory.Delete(downloadDir, true);
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement