Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support method level interception #80

Closed
YuvalItzchakov opened this issue Jan 28, 2015 · 5 comments
Closed

Support method level interception #80

YuvalItzchakov opened this issue Jan 28, 2015 · 5 comments

Comments

@YuvalItzchakov
Copy link

I've been searching around to see if it is possible to use interceptors for method level interception, and came across the following from the docs:

"The InterceptorAttribute is defined in a way that allows you to put it not only on classes, but on any other target where custom attribute is allowed, like interface or a method. However Windsor will ignore the attribute unless it's on component's implementation class. This permissive behavior was introduced to allow people to add support for other targets by building custom extensions."

I think adding a fine grained control for interception at the method level would be a great thing for general purpose aspects such as logging, performance counters, etc.

@jonorossi
Copy link
Member

Could you provide an example of what you'd like to do, maybe a code snippet/pseudocode.

My understanding of your request is currently what you do today with Castle DynamicProxy and/or Castle Windsor. Take a look at the DynamicProxy Introduction.

@YuvalItzchakov
Copy link
Author

Right, so what im trying to do is create an interceptor which will be able to intercept at the method level, for example. Lets say i have class Foo with two methods:

public interface IFoo
{
    void Fooable();
    void Barable();
}

public class Foo : IFoo
{
    [Log]
    public void Fooable()
    {
        Console.WriteLine("In Fooable");
    }

    public void Barable()
    {
        Console.WriteLine("In Barable");
    }
}

I want to intercept only calls on Foo that have a LogAttribute. I don't want the entire class to be intercepted, but only specific methods.

Hope that's clearer. I came across this SO question: http://stackoverflow.com/questions/21148285/castle-windsor-interceptor-not-working-with-method-level-attribute which basically says you can't do that.

@kkozmic
Copy link
Contributor

kkozmic commented Apr 10, 2015

A IProxyGenerationHookcan help you do that

@kkozmic
Copy link
Contributor

kkozmic commented Sep 9, 2015

Can we close this issue? It looks like it's been resolved...

@jonorossi
Copy link
Member

Let us know if IProxyGenerationHook doesn't fulfil your requirements, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants