Try
Try

Reputation:

Postsharp and NLog, general design question

This is what i intend to do:

  1. I want to write a Aspect oriented NLog specific onmethodexecutionaspect class.
  2. But i still want to ensure that the calling code is attributed using a general attribute class which will internally load the NLog or TraceX etc specific implementation of methodexecutionaspect depending on what is specified in the application configuration file.

What is the best way to approach this?

I am thinking of writing a abstract class which will derive from postsharp method execution aspect. Then i will have another dll which will have a NLog specific implementation... so it will have a class which will derive from the general method execution aspect class i have created in the general dll.

The consuming code will only reference the general class dll i have written, and that class will doa load of NLog specific dll i have written if that is what is specified in the application config.

makes sense?

Upvotes: 2

Views: 971

Answers (1)

Gael Fraiteur
Gael Fraiteur

Reputation: 6857

I think you are on the right track. However, try using OnMethodBoundaryAspect instead. It is faster at runtime than OnMethodInvocationAspect.

Try to take advantage of compile-time initialization (CompileTimeInitialize) and run-time initialization (RunTimeInitialize) and avoid doing anything costly in handlers.

Upvotes: 3

Related Questions