예제 #1
0
        public async Task <TorrentAddResponse> AddTorrent(TorrentAddRequest addRequest)
        {
            var request = new TransmissionRequest()
            {
                Method    = GetAttributeOfType <DisplayAttribute, Methods>(Methods.TorrentAdd).Description,
                Arguments = addRequest
            };

            return(await this.ExecuteMethodChecked <TorrentAddResponse>(request));
        }
예제 #2
0
        /// <summary>
        /// Add a new torrent by directly giving a <see cref="TorrentAddRequest"/>. Only do this when you know what you are doing!
        /// </summary>
        /// <param name="arguments">settings for torrent that should be added</param>
        /// <returns>an indicator of success and the new/existing torrent</returns>
        public async Task <TorrentAdded> TorrentAddAsync(TorrentAddRequest arguments)
        {
            var result = await GetResponseAsync <TorrentAddResponse, TorrentAddRequest>(arguments);

            if (result.Added is LightweightTorrent added)
            {
                return new TorrentAdded {
                           Result = TorrentAddResult.Added, Torrent = added
                }
            }
            ;
            if (result.Duplicate is LightweightTorrent duplicate)
            {
                return new TorrentAdded {
                           Result = TorrentAddResult.Duplicate, Torrent = duplicate
                }
            }
            ;
            return(new TorrentAdded {
                Result = TorrentAddResult.Error
            });
        }
    }