Exemplo n.º 1
0
        private static void ValidateNewConceptSameAsExisting(IConceptInfo newConcept, IConceptInfo existingConcept)
        {
            if (newConcept == existingConcept)
            {
                return;
            }

            if (newConcept.GetFullDescription() == existingConcept.GetFullDescription())
            {
                return;
            }

            // The new concept is allowed to be a simple version (base class) of the existing concept, even if it is not the same.
            // This will allow some macro concepts to create simplified new concept that will be ignored if more specific version is already implemented.
            // Note: Unfortunately this logic should not simply be reversed to also ignore old concept if the new concept is a derivation of the old one,
            // because other macros might have already used the old concept to generate a different business logic.
            if (newConcept.GetType().IsAssignableFrom(existingConcept.GetType()) &&
                newConcept.GetFullDescription() == existingConcept.GetFullDescriptionAsBaseConcept(newConcept.GetType()))
            {
                return;
            }

            throw new DslSyntaxException(
                      "Concept with same key is described twice with different values."
                      + "\r\nValue 1: " + existingConcept.GetFullDescription()
                      + "\r\nValue 2: " + newConcept.GetFullDescription()
                      + "\r\nSame key: " + newConcept.GetKey());
        }
Exemplo n.º 2
0
        // The new concept is allowed to be a simple version (base class) of the existing concept, even if it is not the same.
        // This will allow some macro concepts to create simplified new concept that will be ignored if more specific version is already implemented.
        // Note: Unfortunately this logic should not simply be reversed to also ignore old concept if the new concept is a derivation of the old one,
        // because other macros might have already used the old concept to generate a different business logic.
        private void ValidateNewConceptSameAsExisting(IConceptInfo newConcept, IConceptInfo existingConcept)
        {
            _validateDuplicateStopwatch.Start();

            if (newConcept != existingConcept &&
                newConcept.GetFullDescription() != existingConcept.GetFullDescription() &&
                !(newConcept.GetType().IsAssignableFrom(existingConcept.GetType()) &&
                  newConcept.GetFullDescription() == existingConcept.GetFullDescriptionAsBaseConcept(newConcept.GetType())))
            {
                throw new DslSyntaxException(
                          "Concept with same key is described twice with different values."
                          + "\r\nValue 1: " + existingConcept.GetFullDescription()
                          + "\r\nValue 2: " + newConcept.GetFullDescription()
                          + "\r\nSame key: " + newConcept.GetKey());
            }

            _validateDuplicateStopwatch.Stop();
        }