コード例 #1
0
        public Package CreateFromExternalUrl(string key, string fileExtension, string externalPackageUrl)
        {
            ValidateInputs(() => _serviceInputValidator.ValidateUserApiKey(key));
            ValidateInputs(() => _serviceInputValidator.ValidateExternalUrl(externalPackageUrl));

            Func <Package> action = () =>
            {
                using (var client = new ExtendedWebClient(_configSettings.ExternalPackageRequestTimeout))
                {
                    SetUserAgentForCodeplexCompliance(client);
                    byte[] bytes = client.DownloadData(externalPackageUrl);
                    return(_packageCreator.CreatePackage(key, new MemoryStream(bytes), PACKAGE_FILE_EXTENSION, false, externalPackageUrl));
                }
            };

            return(ExecuteAction(action, "The Package could not be created from the external source"));
        }
コード例 #2
0
 public void ValidateExternalUrlShouldThrowWhenGivenInvalidUri(string uri)
 {
     Assert.Throws <WebFaultException <string> >(() => _validator.ValidateExternalUrl(uri));
 }