コード例 #1
0
        private IEnumerable <TorrentStatusKey> GetTorrentStatusKeyFlags(TorrentStatusKey keyFlags)
        {
            Type type   = typeof(TorrentStatusKey);
            var  values = Enum.GetValues(type).Cast <TorrentStatusKey>();

            foreach (TorrentStatusKey value in values)
            {
                if (keyFlags.HasFlag(value))
                {
                    yield return(value);
                }
            }
        }
コード例 #2
0
        public async Task <object[]> GetTorrentStatusAsync(Torrent torrent, TorrentStatusKey keyFlags)
        {
            object[] args = GetTorrentStatusKeyFlags(keyFlags).Select(key => key.GetStatusKeyName()).Cast <object>().ToArray();

            IRPCMessage message = await CallMethodAsync(Method.GetTorrentStatus, new object[] { torrent.TorrentId, args });

            RPCResponse responseMessage = message as RPCResponse;

            if (responseMessage == null)
            {
                HandleError(message as RPCError);
            }

            return(responseMessage.ReturnValues);
        }
コード例 #3
0
        public async Task <Dictionary <object, object> > GetTorrentsStatusAsync(TorrentStatusKey keyFlags)
        {
            object[] args = GetTorrentStatusKeyFlags(keyFlags).Select(key => key.GetStatusKeyName()).Cast <object>().ToArray();

            IRPCMessage message = await CallMethodAsync(Method.GetTorrentsStatus, new object[] { new Dictionary <object, object>(), args });

            RPCResponse response = message as RPCResponse;

            if (response == null)
            {
                HandleError(message as RPCError);
            }

            return(response.ReturnValues.Cast <Dictionary <object, object> >().Single());
        }
 public static string GetStatusKeyName(this TorrentStatusKey value)
 {
     return(value.GetCustomAttribute <StatusKeyNameAttribute>().Name);
 }