public BEncodedDictionary Create(ITorrentFileSource fileSource) { Check.FileSource(fileSource); var mappings = new List<FileMapping>(fileSource.Files); if (mappings.Count == 0) throw new ArgumentException("The file source must contain one or more files", "fileSource"); mappings.Sort((left, right) => left.Destination.CompareTo(right.Destination)); Validate(mappings); var maps = new List<TorrentFile>(); foreach (var m in fileSource.Files) maps.Add(ToTorrentFile(m)); return Create(fileSource.TorrentName, maps); }
public void Create(ITorrentFileSource fileSource, string savePath) { Check.SavePath(savePath); File.WriteAllBytes(savePath, Create(fileSource).Encode()); }
public Task CreateAsync(ITorrentFileSource fileSource, Stream stream, CancellationToken token) => Task.Run(() => Create(fileSource, stream, token));
public Task CreateAsync(ITorrentFileSource fileSource, string savePath) { return(CreateAsync(fileSource, savePath, CancellationToken.None)); }
public IAsyncResult BeginCreate(ITorrentFileSource fileSource, AsyncCallback callback, object asyncState) { return(BeginCreate(() => Create(fileSource), callback, asyncState)); }
public IAsyncResult BeginCreate(ITorrentFileSource fileSource, AsyncCallback callback, object asyncState) { return BeginCreate(delegate { return Create(fileSource); }, callback, asyncState); }
public void Create(ITorrentFileSource fileSource, string savePath) => Create(fileSource, savePath, CancellationToken.None);
public void Create(ITorrentFileSource fileSource, Stream stream) { CreateAsync(fileSource, stream, CancellationToken.None).GetAwaiter().GetResult(); }
public void Create(ITorrentFileSource fileSource, string savePath) { CreateAsync(fileSource, savePath, CancellationToken.None).GetAwaiter().GetResult(); }
public Task <BEncodedDictionary> CreateAsync(ITorrentFileSource fileSource, CancellationToken token) => Task.Run(() => Create(fileSource, token));
public void Create(ITorrentFileSource fileSource, Stream stream) => Create(fileSource, stream, CancellationToken.None);
public BEncodedDictionary Create(ITorrentFileSource fileSource) => Create(fileSource, CancellationToken.None);
void Create(ITorrentFileSource fileSource, string savePath, CancellationToken token) { Check.SavePath(savePath); File.WriteAllBytes(savePath, Create(fileSource, token).Encode()); }
public Task CreateAsync(ITorrentFileSource fileSource, string savePath, CancellationToken token) => Task.Run(() => Create(fileSource, savePath, token));
public void Create(ITorrentFileSource fileSource, Stream stream) { Check.Stream(stream); var data = Create(fileSource).Encode(); stream.Write(data, 0, data.Length); }
public Task <BEncodedDictionary> CreateAsync(ITorrentFileSource fileSource) { return(CreateAsync(fileSource, CancellationToken.None)); }
public Task CreateAsync(ITorrentFileSource fileSource, Stream stream) { return(CreateAsync(fileSource, stream, CancellationToken.None)); }
public static async Task CreateAsync(this TorrentCreator tc, ITorrentFileSource itfs, FileStream stream) { byte[] buffer = (await Task.Factory.FromAsync(tc.BeginCreate, tc.EndCreate, itfs, null)).Encode(); await stream.WriteAsync(buffer, 0, buffer.Length); stream.Close(); }
public BEncodedDictionary Create(ITorrentFileSource fileSource) { Check.FileSource(fileSource); var mappings = new List<FileMapping>(fileSource.Files); if (mappings.Count == 0) throw new ArgumentException("The file source must contain one or more files", "fileSource"); mappings.Sort((left, right) => string.Compare(left.Destination, right.Destination, System.StringComparison.Ordinal)); Validate(mappings); var maps = fileSource.Files .Select(ToTorrentFile) .ToList(); return Create(fileSource.TorrentName, maps); }