ITraceListenerIndenter InterfaceCleanCode C# Libraries v1.2.03 API
An interface for custom TraceListeners for making indentation global.

Namespace: CleanCode.Diagnostics
Assembly: CleanCode (in CleanCode.dll) Version: (1.2.03)

public interface ITraceListenerIndenter

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.

See Also