public CuratedPackage CreatedCuratedPackage( CuratedFeed curatedFeed, Package package, bool included = false, bool automaticallyCurated = false, string notes = null, bool commitChanges = true) { if (curatedFeed == null) { throw new ArgumentNullException("curatedFeed"); } if (package == null) { throw new ArgumentNullException("package"); } var curatedPackageRegistration = curatedFeed.Packages .SingleOrDefault(cp => cp.PackageRegistrationKey == package.PackageRegistration.Key); var isFirstPackageInRegistration = false; if (curatedPackageRegistration == null) { curatedPackageRegistration = new CuratedPackage { PackageRegistration = package.PackageRegistration, PackageRegistrationKey = package.PackageRegistrationKey, Included = included, AutomaticallyCurated = automaticallyCurated, Notes = notes, }; curatedFeed.Packages.Add(curatedPackageRegistration); isFirstPackageInRegistration = true; } if (!curatedPackageRegistration.CuratedPackageVersions.Any(p => p.PackageKey == package.Key)) { var curatedPackageVersion = new CuratedPackageVersion { CuratedFeed = curatedFeed, CuratedFeedKey = curatedFeed.Key, PackageRegistration = package.PackageRegistration, PackageRegistrationKey = package.PackageRegistrationKey, Package = package, PackageKey = package.Key, }; // Make sure we set IsLatest + IsLatestStable for the first package, because // UpdateIsLatest won't be able to see this registration if we don't commit. // If it's the first package in the registration, then it's definitely the // latest. It's the latest stable package only if it's not a pre-release. if (isFirstPackageInRegistration) { curatedPackageVersion.IsLatest = true; curatedPackageVersion.IsLatestStable = !package.IsPrerelease; } curatedPackageRegistration.CuratedPackageVersions.Add(curatedPackageVersion); } if (commitChanges) { CuratedFeedRepository.CommitChanges(); } return curatedPackageRegistration; }
public CuratedPackage CreatedCuratedPackage( CuratedFeed curatedFeed, Package package, bool included = false, bool automaticallyCurated = false, string notes = null, bool commitChanges = true) { if (curatedFeed == null) { throw new ArgumentNullException("curatedFeed"); } if (package == null) { throw new ArgumentNullException("package"); } var curatedPackageRegistration = curatedFeed.Packages .SingleOrDefault(cp => cp.PackageRegistrationKey == package.PackageRegistration.Key); var isFirstPackageInRegistration = false; if (curatedPackageRegistration == null) { curatedPackageRegistration = new CuratedPackage { PackageRegistration = package.PackageRegistration, PackageRegistrationKey = package.PackageRegistrationKey, Included = included, AutomaticallyCurated = automaticallyCurated, Notes = notes, }; curatedFeed.Packages.Add(curatedPackageRegistration); isFirstPackageInRegistration = true; } if (!curatedPackageRegistration.CuratedPackageVersions.Any(p => p.PackageKey == package.Key)) { var curatedPackageVersion = new CuratedPackageVersion { CuratedFeed = curatedFeed, CuratedFeedKey = curatedFeed.Key, PackageRegistration = package.PackageRegistration, PackageRegistrationKey = package.PackageRegistrationKey, Package = package, PackageKey = package.Key, }; // Make sure we set IsLatest + IsLatestStable for the first package, because // UpdateIsLatest won't be able to see this registration if we don't commit. // If it's the first package in the registration, then it's definitely the // latest. It's the latest stable package only if it's not a pre-release. if (isFirstPackageInRegistration) { curatedPackageVersion.IsLatest = true; curatedPackageVersion.IsLatestStable = !package.IsPrerelease; } curatedPackageRegistration.CuratedPackageVersions.Add(curatedPackageVersion); } if (commitChanges) { CuratedFeedRepository.CommitChanges(); } return(curatedPackageRegistration); }