Example #1
0
        /// <summary>
        /// Sets the state of the object based
        /// on the supplied json
        /// </summary>
        /// <param name="json">Json that will be used</param>
        void IJsonLoadable.LoadFromJson(JsonBaseType json)
        {
            JsonArray j = json["root"]["download-dirs"] as JsonArray;

            for (int x = 0; x < j.Count; x++)
            {
                this.internalList.Add(new Directory(j[x]["path"], j[x]["available"]));
            }
        }
Example #2
0
        /// <summary>
        /// Updates the in-memory collection from its json representation
        /// </summary>
        /// <param name="json">the json to load</param>
        void IJsonLoadable.LoadFromJson(JsonBaseType json)
        {
            JsonArray torrents = json["root"]["torrents"] as JsonArray;

            if (torrents != null)
            {
                this.internalCollection.Clear();

                for (int x = 0; x < torrents.Count; x++)
                {
                    this.internalCollection.Add(new Torrent(torrents[x] as JsonArray, this.proxy));
                }
            }
            else
            {
                torrents = json["root"]["torrentp"] as JsonArray;

                for (int x = 0; x < torrents.Count; x++)
                {
                    JsonArray jsonTorrent = torrents[x] as JsonArray;
                    string    hash        = jsonTorrent[0];
                    if (this.internalCollection.Contains(hash))
                    {
                        Torrent torrent = this.internalCollection[hash];
                        (torrent as IJsonLoadable).LoadFromJson(jsonTorrent);
                    }
                    else
                    {
                        this.internalCollection.Add(new Torrent(jsonTorrent, this.proxy));
                    }
                }

                torrents = json["root"]["torrentm"] as JsonArray;
                for (int x = 0; x < torrents.Count; x++)
                {
                    string hash = torrents[x];
                    this.internalCollection.Remove(hash);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Sets all of the properties in the torrent
        /// based on the supplied json
        /// </summary>
        /// <param name="j">json object that represents a torrent</param>
        void IJsonLoadable.LoadFromJson(JsonBaseType j)
        {
            JsonArray json = j as JsonArray;

            this.Hash                = json[0];
            this.Status              = (TorrentStatus)(int)json[1];
            this.Name                = json[2];
            this.SizeInBytes         = json[3];
            this.ProgressInMils      = json[4];
            this.DownloadedBytes     = json[5];
            this.UploadedBytes       = json[6];
            this.RatioInMils         = json[7];
            this.UploadBytesPerSec   = json[8];
            this.DownloadBytesPerSec = json[9];
            this.EtaInSecs           = json[10];
            this.label               = json[11];
            this.PeersConnected      = json[12];
            this.PeersInSwarm        = json[13];
            this.SeedsConnected      = json[14];
            this.SeedsInSwarm        = json[15];
            this.Availability        = json[16];
            this.QueueOrder          = json[17];
            this.RemainingBytes      = json[18];
        }
Example #4
0
        /// <summary>
        /// Sets all of the properties in the torrent
        /// based on the supplied json
        /// </summary>
        /// <param name="j">json object that represents a torrent</param>
        void IJsonLoadable.LoadFromJson(JsonBaseType j)
        {
            JsonArray json = j as JsonArray;

            this.Hash = json[0];
            this.Status = (TorrentStatus)(int)json[1];
            this.Name = json[2];
            this.SizeInBytes = json[3];
            this.ProgressInMils = json[4];
            this.DownloadedBytes = json[5];
            this.UploadedBytes = json[6];
            this.RatioInMils = json[7];
            this.UploadBytesPerSec = json[8];
            this.DownloadBytesPerSec = json[9];
            this.EtaInSecs = json[10];
            this.label = json[11];
            this.PeersConnected = json[12];
            this.PeersInSwarm = json[13];
            this.SeedsConnected = json[14];
            this.SeedsInSwarm = json[15];
            this.Availability = json[16];
            this.QueueOrder = json[17];
            this.RemainingBytes = json[18];
                        this.DownloadUrl = json[19];
                        this.RssFeedUrl = json[20];
                        this.StatusMessage = json[21];
                        this.StreamID = json[22];
                        this.DateAdded = startOfEpoch.AddSeconds((double)json[23]);
                        this.DateCompleted = startOfEpoch.AddSeconds((double)json[24]);
                        this.AppUpdateUrl = json[25];
            this.SavePath = json[26];
        }
Example #5
0
        /// <summary>
        /// Sets all of the properties in the torrent
        /// based on the supplied json
        /// </summary>
        /// <param name="j">json object that represents a torrent</param>
        void IJsonLoadable.LoadFromJson(JsonBaseType j)
        {
            JsonArray json = j as JsonArray;

            this.Hash = json[0];
            this.Status = (TorrentStatus)(int)json[1];
            this.Name = json[2];
            this.SizeInBytes = json[3];
            this.ProgressInMils = json[4];
            this.DownloadedBytes = json[5];
            this.UploadedBytes = json[6];
            this.RatioInMils = json[7];
            this.UploadBytesPerSec = json[8];
            this.DownloadBytesPerSec = json[9];
            this.EtaInSecs = json[10];
            this.label = json[11];
            this.PeersConnected = json[12];
            this.PeersInSwarm = json[13];
            this.SeedsConnected = json[14];
            this.SeedsInSwarm = json[15];
            this.Availability = json[16];
            this.QueueOrder = json[17];
            this.RemainingBytes = json[18];
        }