Capgemini / Cauldron

C# Toolkit
MIT License
77 stars 18 forks source link

IPropertyInterceptor combine with IMethodInterceptorOnExit #82

Open SimonPesant opened 5 years ago

SimonPesant commented 5 years ago

Hi all,

I could not find the information in the wiki so I'm asking here.

I created a small Property Attribute to intercept Properties :

[AttributeUsage(AttributeTargets.Property)]
public sealed class ViewContextAttribute : Attribute, IPropertyInterceptor, IPropertyInterceptorInitialize, IMethodInterceptor, IMethodInterceptorOnExit
{
    [AssignMethod("Get{Name}", true)]
    public Func<bool> _onGetProperty;
    ...
}

When it complies, everything works fine, but I was wondering if when the AssignMethod is found, it could wrap it with the MethodInterceptor functionalities?

[ViewContext()]
public bool IsDraggingEnabled => GetIsDraggingEnabled();

In other words, I want to override the return value of IsDraggingEnabled but never loose the actual value of GetIsDraggingEnabled(); Is it something possible? Thanks for your help. Simon