public static string ToJsonString(this ITransferInfo <DownloadContext> @this) { Guards.ThrowIfNull(@this); //Guards.ThrowIfNot(@this.Status != TransferStatus.Transferring); return(@this.ToJObject().ToString(Formatting.None)); }
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))); }
public static BindableDownloader ToBindable(this ITransferInfo <DownloadContext> @this, Dispatcher uiDispatcher = null) { return(new BindableDownloader(@this, uiDispatcher)); }
public static long GetTotalSize(this ITransferInfo <DownloadContext> @this) { Guards.ThrowIfNull(@this); return(@this.Context?.TotalSize ?? 0); }
public static long GetCompletedSize(this ITransferInfo <DownloadContext> @this) { Guards.ThrowIfNull(@this); return(@this.BlockContexts?.Values.Sum(item => item.CompletedSize) ?? 0); }