示例#1
0
        static void ThrowIfDuplicateArtifacts(ArtifactsConfiguration artifacts, IBuildMessages buildMessages)
        {
            var  idMap          = new Dictionary <ArtifactId, ClrType>();
            bool foundDuplicate = false;

            foreach (var artifactDefinitionEntry in artifacts.GetAllArtifactDefinitions())
            {
                if (idMap.ContainsKey(artifactDefinitionEntry.Key))
                {
                    foundDuplicate = true;
                    var artifactId = artifactDefinitionEntry.Key;
                    var clrType    = idMap[artifactId];

                    buildMessages.Error($"The artifacts '{clrType.TypeString}' and '{artifactDefinitionEntry.Value.Type.TypeString}' has the same ArtifactId: '{artifactId}'");
                }
                else
                {
                    idMap.Add(artifactDefinitionEntry.Key, artifactDefinitionEntry.Value.Type);
                }
            }
            if (foundDuplicate)
            {
                throw new DuplicateArtifact();
            }
        }
        static void WarnIfFeatureMissingFromTopology(ArtifactsConfiguration artifacts, BoundedContextTopology boundedContextTopology, IBuildMessages buildMessages)
        {
            Dictionary <Feature, FeatureName> featureMap = boundedContextTopology.RetrieveAllFeatureIds();

            foreach (var artifact in artifacts)
            {
                if (!featureMap.ContainsKey(artifact.Key))
                {
                    buildMessages.Warning($"Found artifacts under a Feature that does not exist in the topology. Feature: '{artifact.Key}':");
                    buildMessages.Warning("Artifacts:");

                    foreach (var definitionEntry in artifacts.GetAllArtifactDefinitions(artifact.Key))
                    {
                        buildMessages.Warning($"\tArtifact: '{definitionEntry.Key.Value}' - '{definitionEntry.Value.Type.TypeString} @{definitionEntry.Value.Generation.Value}'");
                    }
                }
            }
        }
示例#3
0
        static void WarnIfArtifactNoLongerInStructure(ArtifactsConfiguration artifacts, IEnumerable <Type> types, IBuildMessages messages)
        {
            var artifactDefinitions = new Dictionary <ArtifactId, ArtifactDefinition>();

            foreach (var artifactDefinitionEntry in artifacts.GetAllArtifactDefinitions())
            {
                if (!types.Contains(artifactDefinitionEntry.Value.Type.GetActualType()))
                {
                    artifactDefinitions.Add(artifactDefinitionEntry.Key, artifactDefinitionEntry.Value);
                }
            }
            if (artifactDefinitions.Any())
            {
                messages.Warning("There are artifacts that are not found in the Bounded Context's artifacts file:");
                messages.Warning("Artifacts:");
                foreach (var artifactDefinitionEntry in artifactDefinitions)
                {
                    messages.Warning($"\tArtifact: '{artifactDefinitionEntry.Key.Value}' - '{artifactDefinitionEntry.Value.Type.TypeString} @{artifactDefinitionEntry.Value.Generation.Value}'");
                }
                throw new ArtifactNoLongerInStructure();
            }
        }
示例#4
0
        /// <summary>
        /// Gets a <see cref="ArtifactDefinition"/> that corresponds to the artifact's <see cref="Type"/>
        /// </summary>
        public static ArtifactDefinition GetMatchingArtifactDefinition(this ArtifactsConfiguration artifacts, Type artifact)
        {
            var artifactDefinitions = artifacts.GetAllArtifactDefinitions();

            return(artifactDefinitions.Single(_ => _.Value.Type.GetActualType().Equals(artifact)).Value);
        }
        /// <summary>
        /// Gets the <see cref="ArtifactId"/> that corresponds to the artifact's <see cref="Type"/>.
        /// </summary>
        /// <param name="configuration">The <see cref="ArtifactsConfiguration"/> being extended.</param>
        /// <param name="artifact">The <see cref="Type"/> representing the artifact to get for.</param>
        /// <returns>The <see cref="ArtifactId"/> for the <see cref="Type"/>.</returns>
        public static ArtifactId GetMatchingArtifactId(this ArtifactsConfiguration configuration, Type artifact)
        {
            var artifactDefinitions = configuration.GetAllArtifactDefinitions();

            return(artifactDefinitions.Single(_ => _.Value.Type.GetActualType().Equals(artifact)).Key);
        }