本文整理汇总了C#中SemanticVersion.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SemanticVersion.ToString方法的具体用法?C# SemanticVersion.ToString怎么用?C# SemanticVersion.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SemanticVersion
的用法示例。
在下文中一共展示了SemanticVersion.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PutAsync
public async Task<Hash> PutAsync(long id, SemanticVersion version, IPackage package)
{
#region Preconditions
if (package == null) throw new ArgumentNullException(nameof(package));
#endregion
var key = id.ToString() + "/" + version.ToString();
using (var ms = new MemoryStream())
{
await package.ZipToStreamAsync(ms).ConfigureAwait(false);
var hash = Hash.ComputeSHA256(ms, leaveOpen: true);
var blob = new Blob(ms) {
ContentType = "application/zip"
};
await bucket.PutAsync(key, blob).ConfigureAwait(false);
return hash;
}
}
示例2: GeneralCtorTest
public void GeneralCtorTest()
{
SemanticVersion v = new SemanticVersion(0, 2, 1);
Assert.Equal("0.2.1", v.ToString());
Assert.Equal("0.2.1", v.ToString("C"));
Assert.Equal("0.2.1", v.ToString("G"));
}
示例3: AttemptToGetPackageFromCache
private void AttemptToGetPackageFromCache(string packageId, SemanticVersion version, string feedId, string cacheDirectory, out IPackage downloaded, out string downloadedTo)
{
downloaded = null;
downloadedTo = null;
Log.VerboseFormat("Checking package cache for package {0} {1}", packageId, version.ToString());
var name = GetNameOfPackage(packageId, version.ToString());
fileSystem.EnsureDirectoryExists(cacheDirectory);
var files = fileSystem.EnumerateFilesRecursively(cacheDirectory, name + "*.nupkg");
foreach (var file in files)
{
var package = ReadPackageFile(file);
if (package == null)
continue;
if (!string.Equals(package.Id, packageId, StringComparison.OrdinalIgnoreCase) || !string.Equals(package.Version.ToString(), version.ToString(), StringComparison.OrdinalIgnoreCase))
continue;
downloaded = package;
downloadedTo = file;
}
}
示例4: FullCtorTest
public void FullCtorTest()
{
PreRelease pre = new PreRelease(PreReleaseStage.BETA, 5);
SemanticVersion v = new SemanticVersion(0, 2, 1, pre, 1000);
Assert.Equal("0.2.1-BETA.5+1000", v.ToString());
Assert.Equal("0.2.1-BETA.5", v.ToString("C"));
Assert.Equal("0.2.1", v.ToString("G"));
}
示例5: ComparableCtorTest
public void ComparableCtorTest()
{
PreRelease pre = new PreRelease(PreReleaseStage.ALPHA);
SemanticVersion v = new SemanticVersion(0, 2, 1, pre);
Assert.Equal("0.2.1-ALPHA", v.ToString(""));
Assert.Equal("0.2.1-ALPHA", v.ToString("C"));
Assert.Equal("0.2.1", v.ToString("G"));
}
示例6: GetAllPackages
private IEnumerable<NuDeployPackageInfo> GetAllPackages()
{
IEnumerable<PackageInfo> installedPackages = this.packageConfigurationAccessor.GetInstalledPackages();
foreach (PackageInfo package in installedPackages)
{
string packagePrefix = string.Format("{0}.", package.Id);
var packageDirectories =
this.filesystemAccessor.GetSubDirectories(this.applicationInformation.StartupFolder).Where(
dir => dir.Name.StartsWith(packagePrefix, StringComparison.OrdinalIgnoreCase));
foreach (DirectoryInfo packageDirectory in packageDirectories)
{
string packageVersionString = packageDirectory.Name.Replace(string.Format("{0}.", package.Id), string.Empty);
var packageVersion = new SemanticVersion(packageVersionString);
var isInstalled = packageVersion.ToString().Equals(package.Version);
yield return new NuDeployPackageInfo
{
Id = package.Id,
Version = packageVersion,
Folder = packageDirectory.FullName,
IsInstalled = isInstalled
};
}
}
}
示例7: DownloadPackage
public void DownloadPackage(HttpContextBase context)
{
RouteData routeData = GetRouteData(context);
// Get the package file name from the route
string packageId = routeData.GetRequiredString("packageId");
var version = new SemanticVersion(routeData.GetRequiredString("version"));
string filename = packageId + "." + version.ToString() + ".nupkg";
IPackage requestedPackage = _azureRepository.FindPackage(packageId, version);
if (requestedPackage != null)
{
CloudBlockBlob blob = _azureRepository.GetBlob(requestedPackage);
MemoryStream ms = new MemoryStream();
blob.DownloadToStream(ms);
context.Response.Clear();
context.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", filename));
context.Response.ContentType = "application/octet-stream";
context.Response.BinaryWrite(ms.ToArray());
context.Response.End();
}
else
{
// Package not found
WritePackageNotFound(context, packageId, version);
}
}
示例8: GetVersion
static string GetVersion(SemanticVersion version)
{
if (version != null) {
return version.ToString();
}
return null;
}
示例9: BumpPatchVersion
public void BumpPatchVersion()
{
var semver = new SemanticVersion(Version);
var newVer = new SemanticVersion(semver.Major, semver.Minor, semver.Patch+1,build:null, preRelease: null);
Version = FileVersion = newVer.ToString();
}
示例10: GetAsync
public async Task<Package> GetAsync(long id, SemanticVersion version, Hash hash)
{
var key = prefix + id.ToString() + "/" + version.ToString();
var ms = new MemoryStream();
using (var blob = await bucket.GetAsync(key))
{
using (var data = blob.Open())
{
await data.CopyToAsync(ms).ConfigureAwait(false);
}
}
ms.Position = 0;
var secret = SecretKey.Derive(password, hash.Data);
var protector = new AesProtector(secret); // dispose?
var stream = protector.DecryptStream(ms);
#region Verify the hash
var computedHash = Hash.ComputeSHA256(stream, true);
if (computedHash != hash)
{
throw new IntegrityException(hash.Data, computedHash.Data);
}
#endregion
return ZipPackage.FromStream(stream, false);
}
示例11: PutAsync
public async Task<Hash> PutAsync(long id, SemanticVersion version, IPackage package)
{
var key = prefix + id.ToString() + "/" + version.ToString();
using (var ms = new MemoryStream())
{
await package.ZipToStreamAsync(ms).ConfigureAwait(false);
ms.Position = 0;
var hash = Hash.ComputeSHA256(ms, leaveOpen: true);
var secret = SecretKey.Derive(password, hash.Data);
using (var protector = new AesProtector(secret))
{
using (var packageStream = protector.EncryptStream(ms))
{
var blob = new Blob(packageStream) {
ContentType = "application/zip"
};
await bucket.PutAsync(key, blob).ConfigureAwait(false);
}
}
return hash;
}
}
示例12: WillReturnConflictIfAPackageWithTheIdAndSemanticVersionAlreadyExists
public void WillReturnConflictIfAPackageWithTheIdAndSemanticVersionAlreadyExists()
{
var version = new SemanticVersion("1.0.42");
var nuGetPackage = new Mock<IPackage>();
nuGetPackage.Setup(x => x.Id).Returns("theId");
nuGetPackage.Setup(x => x.Version).Returns(version);
var user = new User();
var packageRegistration = new PackageRegistration
{
Packages = new List<Package> { new Package { Version = version.ToString() } },
Owners = new List<User> { user }
};
var packageSvc = new Mock<IPackageService>();
packageSvc.Setup(x => x.FindPackageRegistrationById(It.IsAny<string>())).Returns(packageRegistration);
var userSvc = new Mock<IUserService>();
userSvc.Setup(x => x.FindByApiKey(It.IsAny<Guid>())).Returns(user);
var controller = CreateController(userSvc: userSvc, packageSvc: packageSvc, packageFromInputStream: nuGetPackage.Object);
// Act
var result = controller.CreatePackagePut(Guid.NewGuid().ToString());
// Assert
Assert.IsType<HttpStatusCodeWithBodyResult>(result);
var statusCodeResult = (HttpStatusCodeWithBodyResult)result;
Assert.Equal(409, statusCodeResult.StatusCode);
Assert.Equal(String.Format(Strings.PackageExistsAndCannotBeModified, "theId", "1.0.42"), statusCodeResult.StatusDescription);
}
示例13: GetPackageDirectory
public virtual string GetPackageDirectory(string packageId, SemanticVersion version)
{
string directory = packageId;
if (_useSideBySidePaths)
{
directory = Path.Combine(directory, version.ToString());
}
return directory;
}
示例14: SemanticVersion
void INuGet.SavePackageVersion(string path, Version version)
{
var manifest = Manifest.ReadFrom(null, false);
var semanticVersion = new SemanticVersion(version);
manifest.Metadata.Version = semanticVersion.ToString();
manifest.Save(null);
}
示例15: StringConstructorParsesValuesCorrectly
public void StringConstructorParsesValuesCorrectly(string version, Version versionValue, string specialValue)
{
// Act
SemanticVersion semanticVersion = new SemanticVersion(version);
// Assert
Assert.Equal(versionValue, semanticVersion.Version);
Assert.Equal(specialValue, semanticVersion.SpecialVersion);
Assert.Equal(version, semanticVersion.ToString());
}