static void LoadDownloads()
 {
     if (_downloads == null)
     {
         _downloads = BackgroundDownloadimpl.LoadDownloads();
     }
 }
示例#2
0
        public static BackgroundDownload Start(BackgroundDownloadConfig config)
        {
            LoadDownloads();
            if (_downloads.ContainsKey(config.filePath))
            {
                throw new ArgumentException("Download of this file is already present");
            }
            var download = new BackgroundDownloadimpl(config);

            _downloads.Add(config.filePath, download);
            SaveDownloads();
            return(download);
        }
        public static BackgroundDownload[] Start(params BackgroundDownloadConfig[] configs)
        {
            lock (typeof(BackgroundDownload))
            {
                LoadDownloads();

                foreach (var config in configs)
                {
                    if (_downloads.ContainsKey(config.filePath))
                    {
                        throw new ArgumentException($"Download of {config.filePath} is already present");
                    }
                    var download = new BackgroundDownloadimpl(config);
                    _downloads.Add(config.filePath, download);
                }
                SaveDownloads();
                return(backgroundDownloads);
            }
        }
 static void SaveDownloads()
 {
     BackgroundDownloadimpl.SaveDownloads(_downloads);
 }