Skip to content

tolgacakir/AOP_Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AOP_Example

This repository was created for StackOverflow question: https://stackoverflow.com/questions/65095249/how-to-access-custom-method-attributes-from-proxygenerationhook-in-castle-dynami

Note: AOPExample.AOP.ProductServiceProxyGenerationHook.ShouldInterceptMethod() have to return true for enabling to intercept all of the ProductService methods. I'm searching the way that it should solve the selecting which methods to intercept. I'm following this article: https://kozmic.net/2009/01/17/castle-dynamic-proxy-tutorial-part-iii-selecting-which-methods-to/

But i want to solve with Attribute-based selecting methods. The author is solving the problem with methodName-based solution like this:

public class FreezableProxyGenerationHook:IProxyGenerationHook
{
    //the method will be intercepted if this method returns true
    public bool ShouldInterceptMethod(Type type, MethodInfo memberInfo)
    {
        return !memberInfo.Name.StartsWith("get_", StringComparison.Ordinal);
    }
  
    public void NonVirtualMemberNotification(Type type, MemberInfo memberInfo)
    {
    }
  
    public void MethodsInspected()
    {
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages