public ArticleCache(ArticlePayload articlePayload) { articlePayload.VerifyNotNull(nameof(articlePayload)); articlePayload.Verify(); ArticlePayload = articlePayload; }
public static bool IsValid(this ArticlePayload subject) { try { subject.Verify(); return(true); } catch (ArgumentException) { return(false); } }
public static ArticlePayload ToArticlePayload(this byte[] subject, ArticleId articleId) { subject.VerifyAssert(x => x?.Length > 0, $"{nameof(subject)} is empty"); articleId.VerifyNotNull(nameof(articleId)); var payload = new ArticlePayload { Id = (string)articleId, PackagePayload = Convert.ToBase64String(subject), Hash = Convert.ToBase64String(MD5.Create().ComputeHash(subject)), }; payload.Verify(); return(payload); }
public static byte[] ToBytes(this ArticlePayload subject) { subject.Verify(); return(Convert.FromBase64String(subject.PackagePayload)); }