Exemplo n.º 1
0
 public static void ValueGeneratorAlreadyConfigured <TEntity>(
     string propertyName, IValueGenerator valueGenerator, IValueGenerator currentValueGenerator)
 => throw new InvalidOperationException(
           string.Format(Resources.ThrowHelper_ValueGeneratorAlreadyConfigured,
                         valueGenerator.GetType().FullName,
                         propertyName,
                         typeof(TEntity).Name,
                         currentValueGenerator.GetType().FullName));
Exemplo n.º 2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="BuildCapability" /> class.
        /// </summary>
        /// <param name="generator">The generator that provides the build functions.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="generator" /> parameter is <c>null</c>.</exception>
        public BuildCapability(IValueGenerator generator)
        {
            generator = generator ?? throw new ArgumentNullException(nameof(generator));

            ImplementedByType = generator.GetType();
            SupportsCreate    = true;

            _createType      = (strategy, type, args) => generator.Generate(strategy, type);
            _createProperty  = (strategy, propertyInfo, args) => generator.Generate(strategy, propertyInfo);
            _createParameter = (strategy, parameterInfo, args) => generator.Generate(strategy, parameterInfo);
            _populate        = (strategy, instance) =>
                               throw new NotSupportedException(
                                         $"{nameof(IValueGenerator)} types do not support populating an instance.");
        }