/// <summary> /// Registers an override instance to use when generating values. /// </summary> /// <typeparam name="TType">The type of instance to override.</typeparam> /// <typeparam name="TValue">The member type to override.</typeparam> /// <param name="builder">The current configuration builder instance.</param> /// <param name="member">The member to override.</param> /// <param name="generator">A handler used to generate the override.</param> /// <returns>The current configuration builder instance.</returns> public static IAutoFakerDefaultConfigBuilder WithOverride <TType, TValue>(this IAutoFakerDefaultConfigBuilder builder, Expression <Func <TType, object> > member, Func <AutoGenerateOverrideContext, TValue> generator) { var memberName = GetMemberName(member); var generatorOverride = new AutoGeneratorMemberOverride <TType, TValue>(memberName, generator); return(builder?.WithOverride(generatorOverride)); }
/// <summary> /// Registers the conventions overrides. /// </summary> /// <param name="builder">The current configuration builder instance.</param> /// <param name="configure">A handler for configuring the conventions.</param> /// <returns>The current configuration builder instance.</returns> public static IAutoFakerDefaultConfigBuilder WithConventions(this IAutoFakerDefaultConfigBuilder builder, Action <AutoConventionConfig> configure = null) { var conventions = CreateConventionsOverride(configure); return(builder?.WithOverride(conventions)); }
/// <summary> /// Registers an override instance to use when generating values. /// </summary> /// <typeparam name="TType">The type of instance to override.</typeparam> /// <param name="builder">The current configuration builder instance.</param> /// <param name="generator">A handler used to generate the override.</param> /// <returns>The current configuration builder instance.</returns> public static IAutoFakerDefaultConfigBuilder WithOverride <TType>(this IAutoFakerDefaultConfigBuilder builder, Func <AutoGenerateOverrideContext, TType> generator) { var generatorOverride = new AutoGeneratorTypeOverride <TType>(generator); return(builder?.WithOverride(generatorOverride)); }