/// <summary> /// Returns <see cref="IValueFormattingService"/> instance for provided <paramref name="parameterInfo"/>. /// The returned formatting service is aware of any <see cref="ParameterFormatterAttribute"/> instance(s) are applied on <paramref name="parameterInfo"/> and would use them to format value before any other configured formatters. /// If many instances of <see cref="ParameterFormatterAttribute"/> are present, they would be applied in <see cref="IOrderedAttribute.Order"/> order. /// </summary> /// <param name="parameterInfo"><see cref="ParameterInfo"/> object describing step or scenario method parameter.</param> /// <returns><see cref="IValueFormattingService"/> instance.</returns> public IValueFormattingService GetValueFormattingServiceFor(ParameterInfo parameterInfo) { var declaredFormatters = parameterInfo.GetCustomAttributes(typeof(ParameterFormatterAttribute), true) .OfType <ParameterFormatterAttribute>() .OrderBy(x => x.Order) .Cast <IConditionalValueFormatter>() .ToArray(); return(ValueFormattingService.WithFormattersOverride(declaredFormatters)); }
/// <summary> /// Constructor. /// </summary> protected CoreMetadataProvider(LightBddConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } ValueFormattingService = new ValueFormattingService(configuration); NameFormatter = configuration.NameFormatterConfiguration().GetFormatter(); _nameParser = new NameParser(NameFormatter); _stepTypeProcessor = new StepTypeProcessor(NameFormatter, configuration.StepTypeConfiguration()); }
/// <summary> /// Constructor. /// </summary> /// <param name="nameFormatter"><see cref="INameFormatter"/> object used to format names.</param> /// <param name="stepTypeConfiguration"><see cref="StepTypeConfiguration"/> object used in providing step metadata.</param> /// <param name="cultureInfoProvider"><see cref="ICultureInfoProvider"/> object used in providing step parameter formatters.</param> /// <param name="valueFormattingConfiguration"><see cref="IValueFormattingService"/> object used to format parameters.</param> protected CoreMetadataProvider(INameFormatter nameFormatter, StepTypeConfiguration stepTypeConfiguration, ICultureInfoProvider cultureInfoProvider, ValueFormattingConfiguration valueFormattingConfiguration) { if (stepTypeConfiguration == null) { throw new ArgumentNullException(nameof(stepTypeConfiguration)); } _valueFormattingService = new ValueFormattingService(valueFormattingConfiguration, cultureInfoProvider); NameFormatter = nameFormatter ?? throw new ArgumentNullException(nameof(nameFormatter)); CultureInfoProvider = cultureInfoProvider ?? throw new ArgumentNullException(nameof(cultureInfoProvider)); _nameParser = new NameParser(nameFormatter); _stepTypeProcessor = new StepTypeProcessor(nameFormatter, stepTypeConfiguration); }