Esempio n. 1
0
        public RegistryPackageVersion CreateVersion()
        {
            var version = new RegistryPackageVersion();

            if (!Versions.Add(version))
            {
                throw new InvalidOperationException("Could not create a new version");
            }
            return(version);
        }
Esempio n. 2
0
        public void AssertNoDuplicates(RegistryPackageType type, RegistryPackageVersion version)
        {
            var hashes             = version.Files.Where(f => f.Hash?.Value != null).Select(f => f.Hash.Value).ToArray();
            var conflictingVersion = Get(type)
                                     .SelectMany(s => s.Versions.Where(v => !ReferenceEquals(v, version)).Select(v => (s, v)))
                                     .FirstOrDefault(x => x.v.Files.Count == hashes.Length && x.v.Files.All(f => hashes.Contains(f.Hash?.Value)));

            if (conflictingVersion.v != null)
            {
                throw new UserInputException($"This version contains exactly the same file count and file hashes as {conflictingVersion.s.Name} v{conflictingVersion.v.Version}.");
            }
        }