Capgemini / Cauldron

C# Toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Init method in interceptor pulling in method/property/etc information for use in the interception

Kazpers opened this issue · comments

Ie. pulling in MethodBase and args (for methods) like this:

public void Init(object instance, MethodBase method, object[] args) {
TestMessages.Record(string.Format("Init: {0} [{1}]", method.DeclaringType.FullName + "." + method.Name, args.Length));
}

Idea taken from MethodDecorator.Fody, but would be very useful for knowing something about the instance and method/property/anything we are weaving.

All 4 kinds of interceptors have the instance (except you are intercepting static), args and MethodBase.
The IMethodInterceptor has it in the OnEnter.
The IPropertyGetterInterceptor has it in the OnGet... In this it is part of PropertyInterceptionInfo.
The IPropertySetterInterceptor has it in the OnSet, also in the PropertyInterceptionInfo.
The IConstructorInterceptor has it also in the OnEnter.

There is also an interface for the property interceptors that force them to move the init to the ctor IPropertyInterceptorInitialize.