Open sandboxFocus

Interface IFormattable

Exposes a Format(UnsafeStringBuilder, FormattingRole) method, which allows an object to format itself into an UnsafeStringBuilder. Logging and caching components rely on the IFormattable interface.

Namespace: PostSharp.Patterns.Formatters
Assembly: PostSharp.Patterns.Common.dll
Syntax
public interface IFormattable
Remarks

Implement this interface in a type whose source code you own, when its representation in logs or cache keys must differ from the result of ToString(), or when formatting is performance-critical. A formatter for IFormattable is registered by default, so the implementation does not need to be registered. The role parameter of Format(UnsafeStringBuilder, FormattingRole) tells whether the object is formatted for logging or for caching. For a type you do not own, derive a class from Formatter<T> instead.

Methods

Name Description
Format(UnsafeStringBuilder, FormattingRole)

Appends a description of the current object to a given UnsafeStringBuilder.

See Also