hendryluk / cormo

.NET Application Framework based on Spring and Java EE CDI
MIT License
5 stars 4 forks source link

Implement Interceptor #6

Closed hendryluk closed 9 years ago

hendryluk commented 9 years ago

Example

[Logged]
public class LoggingInterceptor: IAroundInvokeInterceptor
{
    public virtual object AroundInvoke(IInvocationContext)
    {
         /* .. do something .. */
    }
}

public LoggedAttribute: InterceptorBindingAttribute { }

[Logged]
public class Foo
{
      /* all methods will be intercepted */
}

public class Bar
{
     [Logged]
     public void DoSomething()
     {
           /* only this method will be intercepted */
     }
}

What about events and properties? Most likely yes, it should be able to intercept get/set properties and add/remove events. But perhaps an IPropertyInterceptor and IEventInterceptor is more suited than method-centric IAroundInvokeInterceptor. Java doesn't have properties/events syntax so it's not covered by the CDI spec

hendryluk commented 9 years ago

Implemented in 0.0.1.11 (nuget), which also includes implementation of [Transactional] on Cormo.Data.EntityFramework