Ejemplo n.º 1
0
        /// <summary>
        /// Creates a violation based on the name of a property
        /// </summary>
        public DataCreationStrategy <T> CreateViolation(string propertyName, ViolationType violationType)
        {
            if (!_validations.ContainsKey(propertyName))
            {
                throw new Exception("There is no definition of valid for this property");
            }

            DataCreationStrategy <T> strategy = _defaultCreationStrategy ?? new DataCreationStrategy <T>();

            Validity validation = _validations[propertyName];

            validation.ApplyDataCreationStrategy(propertyName, strategy, violationType);

            return(strategy);
        }