public string GetValidationMessagesAsJson() { var rawMessage = new JsonComparisonMessage { id = Id.ToString(), code = Code.ToString(), message = Message, type = Severity.ToString(), docUrl = DocUrl.ToString(), mode = Mode.ToString(), old = new JsonLocation { @ref = OldJsonRef, path = OldJson()?.Path, location = OldLocation(), }, @new = new JsonLocation { @ref = NewJsonRef, path = NewJson()?.Path, location = NewLocation(), } }; return(JsonConvert.SerializeObject( rawMessage, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore } )); }
/// <inheritdoc /> public override string ToString() { var str = base.ToString(); if (Id != 0) { str += $",Id={Id}"; } if (!Name.IsEmpty()) { str += $",Name={Name}"; } if (!Description.IsEmpty()) { str += $",Descr={Description}"; } if (!PackageId.IsEmpty()) { str += $",PackageId={PackageId},Repo={Repository}"; } if (!Tags.IsEmpty()) { str += $",Tags={Tags}"; } if (Author != 0) { str += $",Author={Author}"; } if (Price != null) { str += $",Price={Price}"; } str += $",Downloads={DownloadCount}"; if (Rating != null) { str += $",Rating={Rating}"; } if (!DocUrl.IsEmpty()) { str += $",Doc={DocUrl}"; } if (Picture != default) { str += $",Picture={Picture}"; } str += $",Connectors={IsRequiredConnectors},Content={ContentType}"; return(str); }
/// <summary> /// Resets the doc regardless if <see cref="ExpiresOn"/> has expired yet. /// Note, this still *does* do a conditional get with the <see cref="ETag"/> /// (where the ETag has to be set and Doc has to be not nulle). To ignore that /// as well set <paramref name="ignoreEtag"/> to true. /// </summary> /// <param name="docUrl">The url to download. Enter this to override /// the current <see cref="DocUrl"/>.</param> /// <param name="ignoreEtag">Set to true to ignore the etag and force /// a full download no matter what.</param> /// <returns>True if a full reset occurred, false if conditional get /// determined current document was already up to date.</returns> public async Task <bool> Reset(string docUrl = null, bool ignoreEtag = false) { if (docUrl.IsNulle()) { docUrl = DocUrl.NullIfEmptyTrimmed(); } if (docUrl.IsNulle()) { throw new ArgumentException($"{nameof(DocUrl)} was null."); } if (!Uri.TryCreate(docUrl, UriKind.Absolute, out Uri uriResult)) { throw new ArgumentException($"{nameof(DocUrl)} was not a valid URI."); } string etag = ignoreEtag || Doc.IsNulle() // never even set etag if doc is null ? null : ETag; string _doc = null; var notModProps = new HttpNotModifiedProperties() { ETag = etag }; var httpRespInfo = await XHttp.GetAsync( DocUrl, settings : notModProps, timeout : TimeSpan.FromSeconds(10)); if (httpRespInfo.NotModified) { return(false); // NotModified can never be true if we didn't send in the etag, but... } _doc = httpRespInfo.Failed ? null : httpRespInfo.GetContentString(); bool isValid = ValidateDownload(_doc); if (!isValid) { throw new Exception("Downloaded string is null or invalid."); } Doc = _doc; this.ETag = httpRespInfo.ETag; LastUpdated = DateTimeOffset.UtcNow; return(true); }
/// <inheritdoc /> public override string ToString() { var str = base.ToString(); if (Id != 0) { str += $",Id={Id}"; } if (!Name.IsEmpty()) { str += $",Name={Name}"; } if (!Description.IsEmpty()) { str += $",Descr={Description}"; } if (!PackageId.IsEmpty()) { str += $",PackageId={PackageId},Repo={Repository}"; } if (!Tags.IsEmpty()) { str += $",Tags={Tags}"; } if (Author != 0) { str += $",Author={Author}"; } if (MonthlyPrice != null || DiscountMonthlyPrice != null || RenewMonthlyPrice != null) { str += $",Monthly={MonthlyPrice},renew={RenewMonthlyPrice},disc={DiscountMonthlyPrice}"; } if (AnnualPrice != null || DiscountAnnualPrice != null || RenewAnnualPrice != null) { str += $",Annual={AnnualPrice},renew={RenewAnnualPrice},disc={DiscountAnnualPrice}"; } if (LifetimePrice != null || DiscountLifetimePrice != null) { str += $",Life={LifetimePrice} (disc={DiscountLifetimePrice})"; } if (RenewPrice != null) { str += $",Renew={RenewPrice}"; } str += $",Downloads={DownloadCount}"; if (Rating != null) { str += $",Rating={Rating}"; } if (!DocUrl.IsEmpty()) { str += $",Doc={DocUrl}"; } if (Picture != default) { str += $",Picture={Picture}"; } str += $",Content={ContentType}"; if (SupportedPlugins != null) { str += $",Supported={SupportedPlugins.Value}"; } if (!Extra.IsEmpty()) { str += $",Extra={Extra}"; } if (!LatestVersion.IsEmpty()) { str += $",Ver={LatestVersion}"; } if (Flags != default) { str += $",Flags={Flags}"; } if (PurchasedTill != default) { str += $",Purchased={PurchasedTill}"; } return(str); }
/// <inheritdoc /> public override string ToString() { var str = base.ToString(); if (Id != 0) { str += $",Id={Id}"; } if (!Name.IsEmpty()) { str += $",Name={Name}"; } if (!Description.IsEmpty()) { str += $",Descr={Description}"; } if (!PackageId.IsEmpty()) { str += $",PackageId={PackageId},Repo={Repository}"; } if (!Tags.IsEmpty()) { str += $",Tags={Tags}"; } if (Author != 0) { str += $",Author={Author}"; } if (Price != null) { str += $",Price={Price}"; } if (RenewPrice != null) { str += $",Renew={RenewPrice}"; } str += $",Downloads={DownloadCount}"; if (Rating != null) { str += $",Rating={Rating}"; } if (!DocUrl.IsEmpty()) { str += $",Doc={DocUrl}"; } if (Picture != default) { str += $",Picture={Picture}"; } str += $",Content={ContentType}"; if (SupportedPlugins != null) { str += $",Supported={SupportedPlugins.Value}"; } if (!Extra.IsEmpty()) { str += $",Extra={Extra}"; } if (!LatestVersion.IsEmpty()) { str += $",Ver={LatestVersion}"; } if (!IsApproved) { str += $",Approved={IsApproved}"; } return(str); }