public static Implementation Build([NotNull] RetrievalMethod retrievalMethod, [NotNull] ITaskHandler handler, bool keepDownloads = false) { #region Sanity checks if (retrievalMethod == null) { throw new ArgumentNullException("retrievalMethod"); } if (handler == null) { throw new ArgumentNullException("handler"); } #endregion var implementationDir = retrievalMethod.DownloadAndApply(handler); try { var digest = GenerateDigest(implementationDir, handler, keepDownloads); return(new Implementation { ID = @"sha1new=" + digest.Sha1New, ManifestDigest = digest, RetrievalMethods = { retrievalMethod } }); } finally { implementationDir.Dispose(); } }
/// <summary> /// Creates a new <see cref="Implementation"/> by completing a <see cref="RetrievalMethod"/> and calculating the resulting <see cref="ManifestDigest"/>. /// </summary> /// <param name="retrievalMethod">The <see cref="RetrievalMethod"/> to use.</param> /// <param name="handler">A callback object used when the the user is to be informed about progress.</param> /// <param name="keepDownloads">Used to retain downloaded implementations; can be <c>null</c>.</param> /// <returns>A newly created <see cref="Implementation"/> containing one <see cref="Archive"/>.</returns> /// <exception cref="OperationCanceledException">The user canceled the task.</exception> /// <exception cref="UriFormatException"><see cref="DownloadRetrievalMethod.Href"/> inside <paramref name="retrievalMethod"/> is a relative URI that cannot be resolved.</exception> /// <exception cref="IOException">There was a problem extracting the archive.</exception> /// <exception cref="WebException">There was a problem downloading the archive.</exception> /// <exception cref="UnauthorizedAccessException">Write access to temporary files was not permitted.</exception> /// <exception cref="NotSupportedException">A <see cref="Archive.MimeType"/> is not supported.</exception> public static Implementation Build(RetrievalMethod retrievalMethod, ITaskHandler handler, IImplementationStore?keepDownloads = null) { #region Sanity checks if (retrievalMethod == null) { throw new ArgumentNullException(nameof(retrievalMethod)); } if (handler == null) { throw new ArgumentNullException(nameof(handler)); } #endregion var implementationDir = retrievalMethod.DownloadAndApply(handler); try { var digest = new Implementation { RetrievalMethods = { retrievalMethod } }; digest.UpdateDigest(implementationDir, handler, new SimpleCommandExecutor(), keepDownloads); return(digest); } finally { implementationDir.Dispose(); } }