AssemblyTraceSource<T> Class

Enable applications to trace the execution of code and associate trace messages with a source named after the assembly the generic type.

Installing

Install via NuGet:

Remarks

This class provides a way to automatically configure trace sources based on the target class (specifically naming the source after the assembly the class is from),which works well with dependency injection frameworks.

If using a dependency injection framework, by simply declaring a dependency of type ITraceSource`T and registering AssemblyTraceSource`T with the dependency injection container, classes will automatically get an ITraceSource based on their assembly name.

Example Remarks

See Examples\AbstractionDependency

The second test example shows how you can use InMemoryTraceListener in your test configuration, and then during testing get a reference to the listener. By clearing the listener before each test, and then checking the contents afterwards, you can apply unit testing to your trace messages in existing code.

Example

{code:c#}
{code:c#}