4

I am working with the new DIP (Dependency Injection) of asp.net 5 https://github.com/aspnet/DependencyInjection. So far I've done pretty well.

But now it's time to do more complex things. As I have done in the past with Windsor Castle or Unity. I need to make a proxy to a class, to intercept calls and log it.

AOP (aspect oriented program)

In Windsord Castle it is called: DinamicProxy In asp.net 5 how i can make the same?

For Example:

public interface ITracingInterceptorHelper
{
    void BeforeCall(string typeName, string methodName, Dictionary<string, object> parameters);
    void ErrorOnCall(string typeName, string methodName, Exception e);
    void AfterCall(string typeName, string methodName, object returnValue);
}


public class TracingInterceptor : BaseInterceptor, IInterceptor
    {
        private readonly ITracingInterceptorHelper _helper;

        public TracingInterceptor(ITracingInterceptorHelper tracingInterceptorHelper)
        {
            _helper = tracingInterceptorHelper;
        }


        public void Intercept(IInvocation invocation)
        {
        //...
        }
    }

Thanks. Regards

Marcelo Oliveto
  • 827
  • 1
  • 9
  • 21

1 Answers1

3

In asp.net 5 how i can make the same?

You can't. This is not possible with the built-in container of ASP.NET 5. The built-in container is not suited for any considerably sized application that follows the SOLID principles and apply AOP.

You should especially not 'downgrade' to the built-in container if the container you are using is working fine for you.

Steven
  • 166,672
  • 24
  • 332
  • 435