18 using System.Collections.Generic;
34 private static readonly
object _fileSystemLock =
new object();
65 string baseFileName =
string.Empty;
66 string extension =
string.Empty;
67 string entryName =
string.Empty;
70 var uri =
new Uri(source);
71 baseFileName = uri.OriginalString;
72 if (!
string.IsNullOrEmpty(uri.Fragment))
74 baseFileName = baseFileName.Replace(uri.Fragment,
"", StringComparison.InvariantCulture);
76 extension = uri.AbsolutePath.GetExtension();
77 entryName = uri.Fragment;
82 extension = Path.GetExtension(baseFileName);
85 var cacheFileName = (useCache ? baseFileName.ToMD5() : Guid.NewGuid().ToString()) + extension;
86 LocalFileName = Path.Combine(downloadDirectory, cacheFileName);
91 lock (_fileSystemLock)
95 bytes = _downloader.
DownloadBytes(source, headers,
null,
null);
101 bytes = _downloader.
DownloadBytes(source, headers,
null,
null);
115 if (!
string.IsNullOrEmpty(entryName))
117 fileNameWithEntry += entryName;
135 get {
return _streamReader.EndOfStream; }
143 return _streamReader.ReadLine();
151 _streamReader.Dispose();
160 _downloader = downloader;