What I have in mind is some sort of logging mechanism. Most of my classes get an ILogger service by dependency injection. What I'd like is to have some sort of "path" information automatically attached to the logging service. By "path" i mean something like "where was the Log()-calling instance injected", all the way up to the top-most scope.
Example:
class A
{
public A(string name, B b, ILogger logger)
{
...
}
}
class B
{
public B(string name, C c, ILogger logger)
{
...
}
}
class C
{
public C(string name, ILogger logger)
{
logger.Log("Hello World");
}
}
Then, when C is created, I want to get this output:
A[nameOfA] -> B[nameOfB] -> C[nameOfC]: Hello World
Any ideas how to achieve this in a generic way, i.e. without manual wiring each class? I already tried to access this information via ParentContext and ParentRequest inside the .ToMethod(..) binding, but didn't come up with a solution.
Best regards Kc