25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

125 lines
2.3 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. namespace Inno.DLC
  4. {
  5. public class DLCGroup
  6. {
  7. public DLCGroup(string id, Dictionary<string, Dictionary<string, string>> values)
  8. {
  9. this._identifier = id;
  10. foreach (KeyValuePair<string, Dictionary<string, string>> keyValuePair in values)
  11. {
  12. DLCFile dlcfile = new DLCFile(keyValuePair.Key, keyValuePair.Value);
  13. this._files.Add(dlcfile.Identifier, dlcfile);
  14. }
  15. }
  16. private DLCGroup()
  17. {
  18. }
  19. public static DLCGroup Merge(params DLCGroup[] groups)
  20. {
  21. DLCGroup dlcgroup = new DLCGroup();
  22. foreach (DLCGroup dlcgroup2 in groups)
  23. {
  24. dlcgroup._identifier = dlcgroup2._identifier;
  25. foreach (DLCFile dlcfile in dlcgroup2.AllFiles)
  26. {
  27. dlcgroup._files[dlcfile.Identifier] = dlcfile;
  28. }
  29. }
  30. return dlcgroup;
  31. }
  32. public string Identifier
  33. {
  34. get
  35. {
  36. return this._identifier;
  37. }
  38. }
  39. public DLCGroup FileSelection(string key, string value)
  40. {
  41. DLCGroup dlcgroup = new DLCGroup();
  42. dlcgroup._identifier = this._identifier;
  43. foreach (DLCFile dlcfile in this._files.Values)
  44. {
  45. if (dlcfile.GetProperty(key) == value)
  46. {
  47. dlcgroup._files.Add(dlcfile.Identifier, dlcfile);
  48. }
  49. }
  50. return dlcgroup;
  51. }
  52. public IList<DLCFile> AllFiles
  53. {
  54. get
  55. {
  56. return new List<DLCFile>(this._files.Values).AsReadOnly();
  57. }
  58. }
  59. public bool IsDownloaded
  60. {
  61. get
  62. {
  63. foreach (DLCFile dlcfile in this._files.Values)
  64. {
  65. if (!dlcfile.Exists)
  66. {
  67. return false;
  68. }
  69. }
  70. return true;
  71. }
  72. }
  73. public long RemainingDownloadSize
  74. {
  75. get
  76. {
  77. long num = 0L;
  78. foreach (DLCFile dlcfile in this._files.Values)
  79. {
  80. if (!dlcfile.Exists)
  81. {
  82. num += dlcfile.Bytes;
  83. }
  84. }
  85. return num;
  86. }
  87. }
  88. public void CheckFiles()
  89. {
  90. foreach (DLCFile dlcfile in this._files.Values)
  91. {
  92. if (dlcfile.Exists && !dlcfile.Check())
  93. {
  94. dlcfile.Delete();
  95. }
  96. }
  97. }
  98. public DLCFile GetFileWithName(string name)
  99. {
  100. foreach (DLCFile dlcfile in this._files.Values)
  101. {
  102. if (dlcfile.Name == name)
  103. {
  104. return dlcfile;
  105. }
  106. }
  107. return null;
  108. }
  109. private string _identifier;
  110. private Dictionary<string, DLCFile> _files = new Dictionary<string, DLCFile>();
  111. }
  112. }