Register<T>(IFormatter<T>)
Registers the given formatter for the type T.
Declaration
public static void Register<T>(IFormatter<T> formatter)Parameters
| Type | Name | Description |
|---|---|---|
| IFormatter<T> | formatter |
Type Parameters
| Name | Description |
|---|---|
| T |
Register(Type, IFormatter)
Registers the given formatter for the given targetType.
Declaration
public static void Register(Type targetType, IFormatter formatter)Parameters
| Type | Name | Description |
|---|---|---|
| Type | targetType | |
| IFormatter | formatter |
Remarks
The formatter works for the given target type and for any type that inherits from or implements the target type.
Register(Type, Type)
Registers the given formatterType for the given targetType.
Declaration
public static void Register(Type targetType, Type formatterType)Parameters
| Type | Name | Description |
|---|---|---|
| Type | targetType | |
| Type | formatterType |
Remarks
Instances of formatterType are created using a parameterless constructor.
When targetType is generic, the registration applies to its generic instantiations
and to types that inherit from or implement them.
Examples
If you register a formatter as
FormattingServices.RegisterFormatter(typeof(IDictionary<,>), typeof(MyDictionaryFormatter<,>))
and then log a parameter of type Dictionary<int, string>, the formatter for that parameter is created
by calling new MyDictionaryFormatter<int, string>.