Ejemplo n.º 1
0
        public Task SetFilePriorityAsync(string hash, IEnumerable <int> fileIds, TorrentContentPriority priority,
                                         CancellationToken token = default)
        {
            ValidateHash(hash);
            if (fileIds == null)
            {
                throw new ArgumentNullException(nameof(fileIds));
            }
            if (!Enum.GetValues(typeof(TorrentContentPriority)).Cast <TorrentContentPriority>().Contains(priority))
            {
                throw new ArgumentOutOfRangeException(nameof(priority));
            }

            var ids = fileIds.ToList();

            if (ids.Any(id => id < 0))
            {
                throw new ArgumentException("The file IDs must be non-negative numbers.", nameof(fileIds));
            }

            return(PostAsync(p => p.SetFilePriority(hash, ids, priority), token, ApiLevel.V2, Version_2_2_0));
        }
Ejemplo n.º 2
0
 public override (Uri url, HttpContent request) SetFilePriority(string hash, IEnumerable <int> fileIds, TorrentContentPriority priority)
 {
     return(BuildForm(Url.SetFilePriority(),
                      ("hash", hash),
                      ("id", string.Join("|", fileIds)),
                      ("priority", priority.ToString("D"))));
 }