コード例 #1
0
        public static string ToJsonString(this ITransferInfo <DownloadContext> @this)
        {
            Guards.ThrowIfNull(@this);
            //Guards.ThrowIfNot(@this.Status != TransferStatus.Transferring);

            return(@this.ToJObject().ToString(Formatting.None));
        }
コード例 #2
0
        public static JObject ToJObject(this ITransferInfo <DownloadContext> @this)
        {
            Guards.ThrowIfNull(@this);
            //Guards.ThrowIfNot(@this.Status != TransferStatus.Transferring);

            return(JObject.FromObject(new DownloadSerializedData
            {
                Context = @this.Context,
                BlockContexts = @this.BlockContexts?.Values.ToList()
            }, JsonSerializer.CreateDefault(JsonExtensions.JsonSerializerSettings)));
        }
コード例 #3
0
 public static BindableDownloader ToBindable(this ITransferInfo <DownloadContext> @this, Dispatcher uiDispatcher = null)
 {
     return(new BindableDownloader(@this, uiDispatcher));
 }
コード例 #4
0
        public static long GetTotalSize(this ITransferInfo <DownloadContext> @this)
        {
            Guards.ThrowIfNull(@this);

            return(@this.Context?.TotalSize ?? 0);
        }
コード例 #5
0
        public static long GetCompletedSize(this ITransferInfo <DownloadContext> @this)
        {
            Guards.ThrowIfNull(@this);

            return(@this.BlockContexts?.Values.Sum(item => item.CompletedSize) ?? 0);
        }