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);
        }
Esempio n. 2
0
        public void Create(ITorrentFileSource fileSource, string savePath)
        {
            Check.SavePath(savePath);

            File.WriteAllBytes(savePath, Create(fileSource).Encode());
        }
Esempio n. 3
0
 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));
 }
Esempio n. 5
0
 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);
 }
Esempio n. 7
0
 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();
 }
Esempio n. 10
0
 public Task <BEncodedDictionary> CreateAsync(ITorrentFileSource fileSource, CancellationToken token)
 => Task.Run(() => Create(fileSource, token));
Esempio n. 11
0
 public void Create(ITorrentFileSource fileSource, Stream stream)
 => Create(fileSource, stream, CancellationToken.None);
Esempio n. 12
0
 public BEncodedDictionary Create(ITorrentFileSource fileSource)
 => Create(fileSource, CancellationToken.None);
Esempio n. 13
0
        void Create(ITorrentFileSource fileSource, string savePath, CancellationToken token)
        {
            Check.SavePath(savePath);

            File.WriteAllBytes(savePath, Create(fileSource, token).Encode());
        }
Esempio n. 14
0
 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);
        }
Esempio n. 16
0
 public Task <BEncodedDictionary> CreateAsync(ITorrentFileSource fileSource)
 {
     return(CreateAsync(fileSource, CancellationToken.None));
 }
        public void Create(ITorrentFileSource fileSource, string savePath)
        {
            Check.SavePath(savePath);

            File.WriteAllBytes(savePath, Create(fileSource).Encode());
        }
Esempio n. 18
0
 public Task CreateAsync(ITorrentFileSource fileSource, Stream stream)
 {
     return(CreateAsync(fileSource, stream, CancellationToken.None));
 }
Esempio n. 19
0
 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();
 }
Esempio n. 20
0
        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);
        }