Exemple #1
0
        private AssemblyVersion GetOrAddAssemblyVersionEntity(Assembly assemblyEntity, AssemblyName assemblyName)
        {
            if (assemblyName.Version == null)
            {
                throw new ArgumentException(null, nameof(assemblyName));
            }
            var assemblyVersion       = assemblyName.Version?.ToString();
            var assemblyVersionEntity = dbContext.AssemblyVersions.FirstOrDefault(s => s.AssemblyId == assemblyEntity.AssemblyId && s.Version == assemblyVersion);

            if (assemblyVersionEntity == null)
            {
                assemblyVersionEntity = new AssemblyVersion
                {
                    AssemblyId      = assemblyEntity.AssemblyId,
                    Version         = assemblyVersion,
                    MajorVersion    = Math.Max(0, assemblyName.Version.Major),
                    MinorVersion    = Math.Max(0, assemblyName.Version.Minor),
                    BuildVersion    = Math.Max(0, assemblyName.Version.Build),
                    RevisionVersion = Math.Max(0, assemblyName.Version.Revision),
                };
                assemblyEntity.AssemblyVersions.Add(assemblyVersionEntity);
                dbContext.SaveChanges();

                Logger.LogInformation($"{assemblyEntity.Name}.{assemblyVersionEntity.Version} assembly added to Assembly database");
            }
            else
            {
                Logger.LogDebug($"{assemblyEntity.Name}.{assemblyVersionEntity.Version} assembly already added to Assembly database. Ignoring.");
            }

            return(assemblyVersionEntity);
        }
Exemple #2
0
        private Assembly GetOrAddAssemblyEntity(AssemblyName assemblyName)
        {
            var normalizedAssemblyName = NormalizedName(assemblyName.Name);
            var assemblyEntity         = dbContext.Assemblies.FirstOrDefault(s => s.Name == normalizedAssemblyName);

            if (assemblyEntity == null)
            {
                assemblyEntity = new Assembly()
                {
                    Name = normalizedAssemblyName,
                };
                dbContext.Assemblies.Add(assemblyEntity);
                dbContext.SaveChanges();

                Logger.LogInformation($"Assembly ({assemblyEntity.Name}) added to database");
            }
            else
            {
                Logger.LogDebug($"Assembly ({assemblyEntity.Name}) already added to database. Ignoring.");
            }

            return(assemblyEntity);
        }
Exemple #3
0
        private PackageVersionAssembly GetOrAddPackageAssemblyVersionEntity(Entity.Package packageEntity, PackageVersion packageVersionEntity, Assembly assemblyEntity, AssemblyVersion assemblyVersionEntity)
        {
            var packageVersionAssemblyEntity = packageVersionEntity.PackageVersionAssemblies.FirstOrDefault(pva => (pva.AssemblyVersion.AssemblyId == assemblyEntity.AssemblyId) && (pva.AssemblyVersion.Version == assemblyVersionEntity.Version));

            if (packageVersionAssemblyEntity == null)
            {
                packageVersionAssemblyEntity = new PackageVersionAssembly()
                {
                    AssemblyVersion = assemblyVersionEntity,
                    PackageVersion  = packageVersionEntity,
                };

                packageVersionEntity.PackageVersionAssemblies.Add(packageVersionAssemblyEntity);
                Logger.LogInformation($"{assemblyEntity.Name}.{assemblyVersionEntity.Version} assembly for package {packageEntity.Name}.{packageVersionEntity.Version} added to PackageVersionAssembly.");
            }
            else
            {
                Logger.LogDebug($"{assemblyEntity.Name}.{assemblyVersionEntity.Version} assembly found for package {packageEntity.Name}.{packageVersionEntity.Version}. Ignoring.");
            }

            return(packageVersionAssemblyEntity);
        }