PostSharp 5.0 / / Post­Sharp Documentation / API Reference / Post­Sharp.​Patterns.​Formatters Namespace / Formatter­Repository(TRole) Class / Formatter­Repository(TRole) Methods / Formatter­Repository(TRole).​Register Method / Formatter­Repository(TRole).​Register Method (Type, Type)

FormatterRepository<TRole>.Register Method (Type, Type)

Registers the given formatterType for the given targetType.

Namespace:  PostSharp.Patterns.Formatters
Assembly:  PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 5.0.55.0 (5.0.55.0)
Syntax
C#
public static void Register(
	Type targetType,
	Type formatterType
)

Parameters

targetType
Type: System.Type
formatterType
Type: System.Type
Remarks

Instances of formatterType are going to be created using a parameterless constructor.

When targetType is generic, the registration applies to its generic instantiations (and types that inherit/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 will be created by calling new MyDictionaryFormatter<int, string>.
See Also