Ejemplo n.º 1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var result = new UTorrentTorrent();

            result.Hash   = reader.ReadAsString();
            result.Status = (UTorrentTorrentStatus)reader.ReadAsInt32();
            result.Name   = reader.ReadAsString();
            reader.Read();
            result.Size     = (long)reader.Value;
            result.Progress = (int)reader.ReadAsInt32() / 1000.0;
            reader.Read();
            result.Downloaded = (long)reader.Value;
            reader.Read();
            result.Uploaded      = (long)reader.Value;
            result.Ratio         = (int)reader.ReadAsInt32() / 1000.0;
            result.UploadSpeed   = (int)reader.ReadAsInt32();
            result.DownloadSpeed = (int)reader.ReadAsInt32();

            result.Eta               = (int)reader.ReadAsInt32();
            result.Label             = reader.ReadAsString();
            result.PeersConnected    = (int)reader.ReadAsInt32();
            result.PeersInSwarm      = (int)reader.ReadAsInt32();
            result.SeedsConnected    = (int)reader.ReadAsInt32();
            result.SeedsInSwarm      = (int)reader.ReadAsInt32();
            result.Availablity       = (int)reader.ReadAsInt32() / 65536.0;
            result.TorrentQueueOrder = (int)reader.ReadAsInt32();
            reader.Read();
            result.Remaining = (long)reader.Value;

            reader.Read();

            // Builds before 25406 don't return the remaining items.

            if (reader.TokenType != JsonToken.EndArray)
            {
                result.DownloadUrl = (string)reader.Value;

                reader.Read();
                result.RssFeedUrl = reader.Value;
                reader.Read();
                result.StatusMessage = reader.Value;
                reader.Read();
                result.StreamId = reader.Value;
                reader.Read();
                result.DateAdded = reader.Value;
                reader.Read();
                result.DateCompleted = reader.Value;
                reader.Read();
                result.AppUpdateUrl     = reader.Value;
                result.RootDownloadPath = reader.ReadAsString();
                reader.Read();
                result.Unknown27 = reader.Value;
                reader.Read();
                result.Unknown28 = reader.Value;

                while (reader.TokenType != JsonToken.EndArray)
                {
                    reader.Read();
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var result = new UTorrentTorrent();

            result.Hash = reader.ReadAsString();
            result.Status = (UTorrentTorrentStatus)reader.ReadAsInt32();
            result.Name = reader.ReadAsString();
            reader.Read();
            result.Size = (long)reader.Value;
            result.Progress = (int)reader.ReadAsInt32() / 1000.0;
            reader.Read();
            result.Downloaded = (long)reader.Value;
            reader.Read();
            result.Uploaded = (long)reader.Value;
            result.Ratio = (int)reader.ReadAsInt32() / 1000.0;
            result.UploadSpeed = (int)reader.ReadAsInt32();
            result.DownloadSpeed = (int)reader.ReadAsInt32();

            result.Eta = (int)reader.ReadAsInt32();
            result.Label = reader.ReadAsString();
            result.PeersConnected = (int)reader.ReadAsInt32();
            result.PeersInSwarm = (int)reader.ReadAsInt32();
            result.SeedsConnected = (int)reader.ReadAsInt32();
            result.SeedsInSwarm = (int)reader.ReadAsInt32();
            result.Availablity = (int)reader.ReadAsInt32() / 65536.0;
            result.TorrentQueueOrder = (int)reader.ReadAsInt32();
            reader.Read();
            result.Remaining = (long)reader.Value;

            reader.Read();

            // Builds before 25406 don't return the remaining items.

            if (reader.TokenType != JsonToken.EndArray)
            {
                result.DownloadUrl = (string)reader.Value;
            
                reader.Read();
                result.RssFeedUrl = reader.Value;
                reader.Read();
                result.StatusMessage = reader.Value;
                reader.Read();
                result.StreamId = reader.Value;
                reader.Read();
                result.DateAdded = reader.Value;
                reader.Read();
                result.DateCompleted = reader.Value;
                reader.Read();
                result.AppUpdateUrl = reader.Value;
                result.RootDownloadPath = reader.ReadAsString();
                reader.Read();
                result.Unknown27 = reader.Value;
                reader.Read();
                result.Unknown28 = reader.Value;
            
                while(reader.TokenType != JsonToken.EndArray)
                    reader.Read();
            }

            return result;
        }