internal static async Task <Uri> BuildDownloadUrlV3Async([NotNull] this DownloadResourceV3 downloadResourceV3, [NotNull] PackageIdentity identity, [NotNull] ILogger logger, CancellationToken token) { if (downloadResourceV3 == null) { throw new ArgumentNullException(nameof(downloadResourceV3)); } if (identity == null) { throw new ArgumentNullException(nameof(identity)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (downloadResourceV3 == null) { throw new ArgumentNullException(nameof(downloadResourceV3)); } var type = downloadResourceV3.GetType(); const string getDownloadUrlMethodName = "GetDownloadUrl"; var getDownloadUrlMethod = type.GetMethod(getDownloadUrlMethodName, BindingFlags.NonPublic | BindingFlags.Instance); if (getDownloadUrlMethod == null) { throw new MissingMethodException(getDownloadUrlMethodName); } var getDownloadUrlTask = (dynamic)getDownloadUrlMethod.Invoke(downloadResourceV3, new object[] { identity, logger, token }); var downloadUri = await getDownloadUrlTask; return(downloadUri as Uri); }
internal static HttpSource BuildHttpSource([NotNull] this DownloadResourceV3 downloadResourceV3) { if (downloadResourceV3 == null) { throw new ArgumentNullException(nameof(downloadResourceV3)); } var type = downloadResourceV3.GetType(); const string httpSourcePrivateReadonlyFieldName = "_client"; var httpSource = type.GetField(httpSourcePrivateReadonlyFieldName, BindingFlags.NonPublic | BindingFlags.Instance); if (httpSource == null) { throw new MissingFieldException(httpSourcePrivateReadonlyFieldName); } return(httpSource.GetValue(downloadResourceV3) as HttpSource); }