Table of Contents

Class ValueFormatterProvider

Namespace
CSF.Screenplay.Reporting
Assembly
CSF.Screenplay.dll

Implementation of IGetsValueFormatter which uses dependency injection services.

public class ValueFormatterProvider : IGetsValueFormatter
Inheritance
ValueFormatterProvider
Implements
Inherited Members

Constructors

ValueFormatterProvider(IServiceProvider, IFormatterRegistry)

Initializes a new instance of ValueFormatterProvider.

public ValueFormatterProvider(IServiceProvider services, IFormatterRegistry registry)

Parameters

services IServiceProvider

A service provider

registry IFormatterRegistry

A registry of the available formatter types

Exceptions

ArgumentNullException

If any parameter is null.

Methods

GetValueFormatter(object)

Selects and returns an IValueFormatter which is most appropriate to the specified value.

public IValueFormatter GetValueFormatter(object value)

Parameters

value object

The value to be formatted

Returns

IValueFormatter

A value formatter

Remarks

See the remarks for IFormatterRegistry for more information about the algorithm by which an appropriate formatter is selected.

It should be very rare for this method to raise an exception; as implementations of this type should come pre-loaded with fallback formatters which may format any value. Exceptions might only be expected if a developer removes these default formatters and does not replace them with suitable implementaton types that can cover all scenarios.

Exceptions

InvalidOperationException

If no appropriate formatter could be selected