本文整理汇总了C#中NuGetGallery.Package类的典型用法代码示例。如果您正苦于以下问题:C# Package类的具体用法?C# Package怎么用?C# Package使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Package类属于NuGetGallery命名空间,在下文中一共展示了Package类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WillCopySenderIfAsked
public void WillCopySenderIfAsked()
{
var from = new MailAddress("[email protected]", "too");
var package = new Package
{
PackageRegistration = new PackageRegistration { Id = "smangit" },
Version = "1.42.0.1",
};
var messageService = new TestableMessageService();
var reportPackageRequest = new ReportPackageRequest
{
AlreadyContactedOwners = true,
FromAddress = from,
Message = "Abuse!",
Package = package,
Reason = "Reason!",
RequestingUser = new User
{
Username = "Joe Schmoe",
EmailAddress = "[email protected]"
},
Url = TestUtility.MockUrlHelper(),
CopySender = true,
};
messageService.ReportAbuse(reportPackageRequest);
var message = messageService.MockMailSender.Sent.Single();
Assert.Equal(TestGalleryOwner, message.To.Single());
Assert.Equal(TestGalleryOwner, message.From);
Assert.Equal(reportPackageRequest.FromAddress, message.ReplyToList.Single());
Assert.Equal(reportPackageRequest.FromAddress, message.CC.Single());
Assert.DoesNotContain("Owners", message.Body);
}
示例2: ReportAbuse
public MailMessage ReportAbuse(MailAddress fromAddress, Package package, string message)
{
string subject = "[{0}] Abuse Report for Package '{1}' Version '{2}'";
string body = @"_User {0} ({1}) reports the package '{2}' version '{3}' as abusive.
{0} left the following information in the report:_
{4}
_Message sent from {5}_
";
body = String.Format(body,
fromAddress.DisplayName,
fromAddress.Address,
package.PackageRegistration.Id,
package.Version,
message,
settings.GalleryOwnerName);
using (
var mailMessage = new MailMessage
{
Subject = String.Format(subject, settings.GalleryOwnerName, package.PackageRegistration.Id, package.Version),
Body = body,
From = fromAddress,
})
{
mailMessage.To.Add(settings.GalleryOwnerEmail);
SendMessage(mailMessage);
return mailMessage;
}
}
示例3: ExecuteAsync
public async Task ExecuteAsync(Package galleryPackage, PackageArchiveReader nugetPackage, bool commitChanges)
{
foreach (var curator in _curators)
{
await curator.CurateAsync(galleryPackage, nugetPackage, commitChanges: commitChanges);
}
}
示例4: Curate
public override void Curate(
Package galleryPackage,
IPackage nugetPackage)
{
var curatedFeed = GetService<ICuratedFeedByNameQuery>().Execute("webmatrix");
if (curatedFeed == null)
return;
if (!galleryPackage.IsLatestStable)
return;
var shouldBeIncluded = galleryPackage.Tags != null && galleryPackage.Tags.ToLowerInvariant().Contains("aspnetwebpages");
if (!shouldBeIncluded)
{
shouldBeIncluded = true;
foreach (var file in nugetPackage.GetFiles())
{
var fi = new FileInfo(file.Path);
if (fi.Extension == ".ps1" || fi.Extension == ".t4")
{
shouldBeIncluded = false;
break;
}
}
}
if (shouldBeIncluded)
GetService<ICreateCuratedPackageCommand>().Execute(
curatedFeed.Key,
galleryPackage.PackageRegistration.Key,
automaticallyCurated: true);
}
示例5: ReportAbuse
public void ReportAbuse(MailAddress fromAddress, Package package, string message)
{
const string subject = "[{0}] Abuse Report for Package '{1}' Version '{2}'";
string body = @"_User {0} ({1}) reports the package '{2}' version '{3}' as abusive.
{0} left the following information in the report:_
{4}
_Message sent from {5}_
";
body = String.Format(
CultureInfo.CurrentCulture,
body,
fromAddress.DisplayName,
fromAddress.Address,
package.PackageRegistration.Id,
package.Version,
message,
_settings.GalleryOwnerName);
using (var mailMessage = new MailMessage())
{
mailMessage.Subject = String.Format(
CultureInfo.CurrentCulture, subject, _settings.GalleryOwnerName, package.PackageRegistration.Id, package.Version);
mailMessage.Body = body;
mailMessage.From = fromAddress;
mailMessage.To.Add(_settings.GalleryOwnerEmail);
SendMessage(mailMessage);
}
}
示例6: ShouldCuratePackage
internal static bool ShouldCuratePackage(
CuratedFeed curatedFeed,
Package galleryPackage,
INupkg nugetPackage)
{
if (!galleryPackage.IsLatestStable)
{
return false;
}
bool shouldBeIncluded = galleryPackage.Tags != null &&
galleryPackage.Tags.ToLowerInvariant().Contains("aspnetwebpages");
if (!shouldBeIncluded)
{
shouldBeIncluded = true;
foreach (var filePath in nugetPackage.GetFiles())
{
var fi = new FileInfo(filePath);
if (fi.Extension == ".ps1" || fi.Extension == ".t4")
{
return false;
}
}
}
if (!shouldBeIncluded)
{
return false;
}
return DependenciesAreCurated(galleryPackage, curatedFeed);
}
示例7: PackageViewModel
public PackageViewModel(Package package)
{
this.package = package;
Version = package.Version;
Description = package.Description;
ReleaseNotes = package.ReleaseNotes;
IconUrl = package.IconUrl;
ProjectUrl = package.ProjectUrl;
ProjectSourceUrl = package.ProjectSourceUrl;
PackageSourceUrl = package.PackageSourceUrl;
DocsUrl = package.DocsUrl;
MailingListUrl = package.MailingListUrl;
BugTrackerUrl = package.BugTrackerUrl;
LicenseUrl = package.LicenseUrl;
LatestVersion = package.IsLatest;
LatestStableVersion = package.IsLatestStable;
LastUpdated = package.Status == PackageStatusType.Submitted ? package.LastUpdated : package.Published;
PublishedDate = package.Published;
Listed = package.Listed;
DownloadCount = package.DownloadCount;
Prerelease = package.IsPrerelease;
Status = package.Status;
SubmittedStatus = package.SubmittedStatus;
ApprovedDate = package.ApprovedDate;
ReviewerUserName = package.ReviewedBy != null ? package.ReviewedBy.Username : string.Empty;
ReviewerEmailAddress = package.ReviewedBy != null ? package.ReviewedBy.EmailAddress : string.Empty;
ReviewedDate = package.ReviewedDate;
ReviewComments = package.ReviewComments;
}
示例8: IdConflictsWithExistingPackageTitleTests
public void IdConflictsWithExistingPackageTitleTests(string existingPackageId, string existingPackageTitle, string newPackageId, bool shouldBeConflict)
{
// Arrange
var existingPackageRegistration = new PackageRegistration
{
Id = existingPackageId,
Owners = new HashSet<User>()
};
var existingPackage = new Package
{
PackageRegistration = existingPackageRegistration,
Version = "1.0.0",
Title = existingPackageTitle
};
var packageRegistrationRepository = new Mock<IEntityRepository<PackageRegistration>>();
packageRegistrationRepository.Setup(r => r.GetAll()).Returns(new[] { existingPackageRegistration }.AsQueryable());
var packageRepository = new Mock<IEntityRepository<Package>>();
packageRepository.Setup(r => r.GetAll()).Returns(new[] { existingPackage }.AsQueryable());
var target = new PackageNamingConflictValidator(packageRegistrationRepository.Object, packageRepository.Object);
// Act
var result = target.IdConflictsWithExistingPackageTitle(newPackageId);
// Assert
Assert.True(result == shouldBeConflict);
}
示例9: PackageViewModel
public PackageViewModel(Package package)
{
_package = package;
Version = String.IsNullOrEmpty(package.NormalizedVersion) ?
SemanticVersionExtensions.Normalize(package.Version) :
package.NormalizedVersion;
Description = package.Description;
ReleaseNotes = package.ReleaseNotes;
IconUrl = package.IconUrl;
ProjectUrl = package.ProjectUrl;
LicenseUrl = package.LicenseUrl;
HideLicenseReport = package.HideLicenseReport;
LatestVersion = package.IsLatest;
LatestStableVersion = package.IsLatestStable;
LastUpdated = package.Published;
Listed = package.Listed;
DownloadCount = package.DownloadCount;
Prerelease = package.IsPrerelease;
LicenseReportUrl = package.LicenseReportUrl;
var licenseNames = package.LicenseNames;
if (!String.IsNullOrEmpty(licenseNames))
{
LicenseNames = licenseNames.Split(',').Select(l => l.Trim());
}
}
示例10: ManagePackageOwnersViewModel
public ManagePackageOwnersViewModel(Package package, IPrincipal currentUser)
: base(package)
{
CurrentOwnerUsername = currentUser.Identity.Name;
OtherOwners = Owners.Where(o => o.Username != CurrentOwnerUsername);
OtherOwners = new[] { new User { Username = "Phil" } };
}
示例11: PackageIndexEntity
public PackageIndexEntity(Package package, int curatedFeedKey, bool isLatest, bool isLatestStable)
{
this.Package = package;
this.curatedFeedKey = curatedFeedKey;
this.isLatest = isLatest;
this.isLatestStable = isLatestStable;
}
示例12: StartEditPackageRequest
public virtual void StartEditPackageRequest(Package p, EditPackageVersionRequest request, User editingUser)
{
PackageEdit edit = new PackageEdit
{
// Description
User = editingUser,
Authors = request.Authors,
Copyright = request.Copyright,
Description = request.Description,
IconUrl = request.IconUrl,
LicenseUrl = p.LicenseUrl, // Our current policy is not to allow editing the license URL, so just clone it from its previous value.
ProjectUrl = request.ProjectUrl,
ReleaseNotes = request.ReleaseNotes,
RequiresLicenseAcceptance = request.RequiresLicenseAcceptance,
Summary = request.Summary,
Tags = request.Tags,
Title = request.VersionTitle,
// Other
Package = p,
Timestamp = DateTime.UtcNow,
TriedCount = 0,
};
EntitiesContext.Set<PackageEdit>().Add(edit);
// Note: EditPackageRequests are completed asynchronously by the worker role.
}
示例13: ShouldCuratePackage
internal static bool ShouldCuratePackage(
CuratedFeed curatedFeed,
Package galleryPackage,
INupkg nugetPackage)
{
return
// Must have min client version of null or <= 2.2
(nugetPackage.Metadata.MinClientVersion == null || nugetPackage.Metadata.MinClientVersion <= new Version(2, 2)) &&
// Must be latest stable
galleryPackage.IsLatestStable &&
// Must support net40
SupportsNet40(galleryPackage) &&
// Dependencies on the gallery must be curated
DependenciesAreCurated(galleryPackage, curatedFeed) &&
(
// Must have AspNetWebPages tag
ContainsAspNetWebPagesTag(galleryPackage) ||
// OR: Must not contain powershell or T4
DoesNotContainUnsupportedFiles(nugetPackage)
);
}
示例14: CreateNuGetExeDownloadExtractsFileIfItDoesNotExist
public async Task CreateNuGetExeDownloadExtractsFileIfItDoesNotExist()
{
// Arrange
var fileStorage = new Mock<IFileStorageService>(MockBehavior.Strict);
fileStorage.Setup(s => s.FileExistsAsync("downloads", "nuget.exe")).Returns(Task.FromResult(false));
fileStorage.Setup(s => s.SaveFileAsync("downloads", "nuget.exe", It.IsAny<Stream>()))
.Returns(Task.FromResult(0))
.Verifiable();
fileStorage.Setup(s => s.CreateDownloadFileActionResultAsync("downloads", "nuget.exe"))
.Returns(Task.FromResult(Mock.Of<ActionResult>()))
.Verifiable();
var package = new Package { Version = "2.0.0" };
var packageService = new Mock<IPackageService>(MockBehavior.Strict);
packageService.Setup(s => s.FindPackageByIdAndVersion("NuGet.CommandLine", null, false))
.Returns(package)
.Verifiable();
var packageFileService = new Mock<IPackageFileService>(MockBehavior.Strict);
packageFileService.Setup(s => s.DownloadPackageFileAsync(package))
.Returns(Task.FromResult(CreateCommandLinePackage()))
.Verifiable();
// Act
var downloaderService = GetDownloaderService(packageService, packageFileService, fileStorage);
await downloaderService.CreateNuGetExeDownloadActionResultAsync();
// Assert
packageFileService.Verify();
packageService.Verify();
}
示例15: DisplayPackageViewModel
public DisplayPackageViewModel(Package package, IOrderedEnumerable<Package> packageHistory, bool isVersionHistory)
: base(package)
{
Copyright = package.Copyright;
if (!isVersionHistory)
{
Dependencies = new DependencySetsViewModel(package.Dependencies);
PackageVersions = packageHistory.Select(p => new DisplayPackageViewModel(p, packageHistory, isVersionHistory: true));
}
DownloadCount = package.DownloadCount;
LastEdited = package.LastEdited;
if (!isVersionHistory && packageHistory.Any())
{
// calculate the number of days since the package registration was created
// round to the nearest integer, with a min value of 1
// divide the total download count by this number
TotalDaysSinceCreated = Convert.ToInt32(Math.Max(1, Math.Round((DateTime.UtcNow - packageHistory.Last().Created).TotalDays)));
DownloadsPerDay = TotalDownloadCount / TotalDaysSinceCreated; // for the package
}
else
{
TotalDaysSinceCreated = 0;
DownloadsPerDay = 0;
}
}