CleanCode C# Libraries v0.9.22 API

ITraceListenerIndenter Interface

An interface for custom TraceListeners for making indentation global.

For a list of all members of this type, see ITraceListenerIndenter Members.

public interface ITraceListenerIndenter

Types that implement ITraceListenerIndenter

Type Description
AlignedTextWriterTraceListener Directs tracing or debugging output to a TextWriter or to a Stream, formatted such that the message indents but all other attributes are always vertically aligned.

Remarks

Indentation for regular TraceListener objects is shared by all TraceListeners of a given type as long as they are within the same executable file. If one is referenced in a referenced library-- even a shared listener--then the indentation for each is separate. I suspect that behavior is probably a bug. This interfaces allows custom TraceListeners to compensate for that. Any such custom object that implements ITraceListenerIndenter will use a global (static) indentation level (GlobalIndentLevel property) instead of the regular IndentLevel property of the class.

Implementing this interface means only supporting one property. The implementation does not need to vary from one class to another but since C# does not support multiple inheritance, this code cannot be inherited at the same time you inherit from a base TraceListener. So standard code to implement is:

private static int globalIndentLevel;
public int GlobalIndentLevel
{
  get { return globalIndentLevel; }
  set { globalIndentLevel = value; }
}

Since CleanCode 0.9.20.

Requirements

Namespace: CleanCode.Diagnostics

Assembly: CleanCode (in CleanCode.dll)

See Also

ITraceListenerIndenter Members | CleanCode.Diagnostics Namespace