|
- using System;
- using System.Collections.Generic;
-
- namespace Inno.DLC
- {
- public class DLCGroup
- {
- public DLCGroup(string id, Dictionary<string, Dictionary<string, string>> values)
- {
- this._identifier = id;
- foreach (KeyValuePair<string, Dictionary<string, string>> keyValuePair in values)
- {
- DLCFile dlcfile = new DLCFile(keyValuePair.Key, keyValuePair.Value);
- this._files.Add(dlcfile.Identifier, dlcfile);
- }
- }
-
- private DLCGroup()
- {
- }
-
- public static DLCGroup Merge(params DLCGroup[] groups)
- {
- DLCGroup dlcgroup = new DLCGroup();
- foreach (DLCGroup dlcgroup2 in groups)
- {
- dlcgroup._identifier = dlcgroup2._identifier;
- foreach (DLCFile dlcfile in dlcgroup2.AllFiles)
- {
- dlcgroup._files[dlcfile.Identifier] = dlcfile;
- }
- }
- return dlcgroup;
- }
-
- public string Identifier
- {
- get
- {
- return this._identifier;
- }
- }
-
- public DLCGroup FileSelection(string key, string value)
- {
- DLCGroup dlcgroup = new DLCGroup();
- dlcgroup._identifier = this._identifier;
- foreach (DLCFile dlcfile in this._files.Values)
- {
- if (dlcfile.GetProperty(key) == value)
- {
- dlcgroup._files.Add(dlcfile.Identifier, dlcfile);
- }
- }
- return dlcgroup;
- }
-
- public IList<DLCFile> AllFiles
- {
- get
- {
- return new List<DLCFile>(this._files.Values).AsReadOnly();
- }
- }
-
- public bool IsDownloaded
- {
- get
- {
- foreach (DLCFile dlcfile in this._files.Values)
- {
- if (!dlcfile.Exists)
- {
- return false;
- }
- }
- return true;
- }
- }
-
- public long RemainingDownloadSize
- {
- get
- {
- long num = 0L;
- foreach (DLCFile dlcfile in this._files.Values)
- {
- if (!dlcfile.Exists)
- {
- num += dlcfile.Bytes;
- }
- }
- return num;
- }
- }
-
- public void CheckFiles()
- {
- foreach (DLCFile dlcfile in this._files.Values)
- {
- if (dlcfile.Exists && !dlcfile.Check())
- {
- dlcfile.Delete();
- }
- }
- }
-
- public DLCFile GetFileWithName(string name)
- {
- foreach (DLCFile dlcfile in this._files.Values)
- {
- if (dlcfile.Name == name)
- {
- return dlcfile;
- }
- }
- return null;
- }
-
- private string _identifier;
-
- private Dictionary<string, DLCFile> _files = new Dictionary<string, DLCFile>();
- }
- }
|