コード例 #1
0
        internal static Torrent Create(Model model)
        {
            var t = new Torrent();

            t.Update(model);
            return(t);
        }
コード例 #2
0
 internal void Update(Model model)
 {
     AddedOn    = model.added_on.GetValueOrDefault(AddedOn);
     AmountLeft = model.amount_left.GetValueOrDefault(AmountLeft);
     AutomaticTorrentManagement = model.auto_tmm.GetValueOrDefault(AutomaticTorrentManagement);
     Availability      = model.availability.GetValueOrDefault(Availability);
     Category          = model.category.GetValueOrDefault(Category);
     Completed         = model.completed.GetValueOrDefault(Completed);
     CompletionOn      = model.completion_on.GetValueOrDefault(CompletionOn);
     ContentPath       = model.content_path.GetValueOrDefault(ContentPath);
     DownloadLimit     = model.dl_limit.GetValueOrDefault(DownloadLimit);
     DownloadSpeed     = model.dlspeed.GetValueOrDefault(DownloadSpeed);
     Downloaded        = model.downloaded.GetValueOrDefault(Downloaded);
     DownloadedSession = model.downloaded_session.GetValueOrDefault(DownloadedSession);
     if (model.eta.IsSpecified)
     {
         ETA = TimeSpan.FromSeconds(model.eta.Value);
     }
     FirstLastPiecePriority = model.f_l_piece_prio.GetValueOrDefault(FirstLastPiecePriority);
     ForceStart             = model.force_start.GetValueOrDefault(ForceStart);
     Hash               = model.hash.GetValueOrDefault(Hash);
     LastActivity       = model.last_activity.GetValueOrDefault(LastActivity);
     MagnetUri          = model.magnet_uri.GetValueOrDefault(MagnetUri);
     MaxRatio           = model.max_ratio.GetValueOrDefault(MaxRatio);
     MaxSeedingTime     = model.max_seeding_time.GetValueOrDefault(MaxSeedingTime);
     Name               = model.name.GetValueOrDefault(Name);
     SwarmSeeds         = model.num_complete.GetValueOrDefault(SwarmSeeds);
     SwarmLeeches       = model.num_incomplete.GetValueOrDefault(SwarmLeeches);
     ConnectedLeeches   = model.num_leechs.GetValueOrDefault(ConnectedLeeches);
     ConnectedSeeds     = model.num_seeds.GetValueOrDefault(ConnectedSeeds);
     Priority           = model.priority.GetValueOrDefault(Priority);
     Progress           = model.progress.GetValueOrDefault(Progress);
     Ratio              = model.ratio.GetValueOrDefault(Ratio);
     RatioLimit         = model.ratio_limit.GetValueOrDefault(RatioLimit);
     SavePath           = model.save_path.GetValueOrDefault(SavePath);
     SeedingTimeLimit   = model.seeding_time_limit.GetValueOrDefault(SeedingTimeLimit);
     SeenComplete       = model.seen_complete.GetValueOrDefault(SeenComplete);
     SequentialDownload = model.seq_dl.GetValueOrDefault(SequentialDownload);
     Size               = model.size.GetValueOrDefault(Size);
     if (model.state.IsSpecified)
     {
         State = Enum.Parse <TorrentState>(model.state.Value, true);
     }
     SuperSeeding = model.super_seeding.GetValueOrDefault(SuperSeeding);
     if (model.tags.IsSpecified)
     {
         Tags = model.tags.Value.Split(",").ToImmutableArray();
     }
     if (model.time_active.IsSpecified)
     {
         TimeActive = TimeSpan.FromSeconds(model.time_active.Value);
     }
     TotalSize       = model.total_size.GetValueOrDefault(TotalSize);
     Tracker         = model.tracker.GetValueOrDefault(Tracker);
     UpLimit         = model.up_limit.GetValueOrDefault(UpLimit);
     Uploaded        = model.uploaded.GetValueOrDefault(Uploaded);
     UploadedSession = model.uploaded_session.GetValueOrDefault(UploadedSession);
     UploadSpeed     = model.upspeed.GetValueOrDefault(UploadSpeed);
 }