Say we have a property like this:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class LogScopeAttribute : Attribute
{
public string Level { get; private set; }
public LogScopeAttribute(string level)
{
Level = level;
}
}
Used in a context like this:
public class Cat
{
[Log.Scope("Important")]
public void Walk()
{
}
[Log.Scope("Trivial")]
public void Sit()
{
}
}
How can I use the property Level
in my Before
and After
methods? It seems like you can only use the fluent interface, but because of that I can't refer to the LogScope
attribute.
public class LoggingAmender : Amendment<object, object>
{
public LoggingAmender()
{
Methods.Where( m => [...] )
.Before(LogScope.LogMethodBefore); // how can I refer to 'Level' of LogScope here?
}
}