/// <summary> /// Stores and reports string content. /// </summary> public void HashAndReportStringContent(string content, FileArtifact file) { var bytes = Encoding.UTF8.GetBytes(content); var hash = ContentHashingUtilities.HashBytes(bytes); FileContentManager.ReportInputContent( file, FileMaterializationInfo.CreateWithUnknownName( new FileContentInfo(hash, bytes.Length))); }
/// <summary> /// Stores and reports string content. /// </summary> public async Task StoreAndReportStringContent(string content, FileArtifact file) { var bytes = Encoding.UTF8.GetBytes(content); var hash = ContentHashingUtilities.HashBytes(bytes); var artifactCache = Environment.Cache.ArtifactContentCache; using (var stream = new MemoryStream(bytes)) { var storeResult = await artifactCache.TryStoreAsync(stream, hash); XAssert.IsTrue(storeResult.Succeeded); FileContentManager.ReportInputContent( file, FileMaterializationInfo.CreateWithUnknownName( new FileContentInfo(hash, bytes.Length))); } }