Ejemplo n.º 1
0
            public SourceToTargetEnvironmentMap(EnvironmentResource[] environmentsToMigrate, EnvironmentResource[] existingEnvironments)
            {
                var expectedTargetEnvironmentNames =
                    environmentsToMigrate.Select(Conventions.BuildTargetEnvironmentNameFromSourceEnvironment)
                    .Distinct()
                    .OrderBy(name => name)
                    .ToArray();
                var targetEnvironments = existingEnvironments.Where(
                    e => expectedTargetEnvironmentNames.Contains(e.Name, StringComparer.OrdinalIgnoreCase))
                                         .ToArray();

                MissingTargetEnvironmentNames =
                    expectedTargetEnvironmentNames.Except(targetEnvironments.Select(e => e.Name)).ToArray();

                if (!MissingTargetEnvironmentNames.Any())
                {
                    sourcesAndTargets = environmentsToMigrate
                                        .Select(source => new SourceAndTargetEnvironment(source, targetEnvironments.FirstOrDefault(target => string.Equals(target.Name, Conventions.BuildTargetEnvironmentNameFromSourceEnvironment(source), StringComparison.OrdinalIgnoreCase))))
                                        .ToArray();
                }
            }