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

特性无法拦截,是没考虑到这种场景,还是根本不支持呢? #301

Open
zhoudi94 opened this issue Mar 10, 2023 · 1 comment

Comments

@zhoudi94
Copy link

`public interface IAccountService
{
public void DoWork();
}

public class AccountService : IAccountService
{
    public AccountService() { 
    
    }

   
    public  void DoWork()
    {
        Work1();
        Work2();
        Work3();
    }

    public  void Work1()
    {
        Console.WriteLine("Work1");
    }

    [CustomInterceptor("Test")]
    public  void Work2()
    {
        Console.WriteLine("Work2");
    }

    public  void Work3()
    {
        Console.WriteLine("Work3");
    }
}`

当我把 [CustomInterceptor("Test")] 设置到DoWork方法上,是可以正常拦截的,但是我设置在Work2 上面就无法正常拦截了,这是为什么呢?

我有特殊的场景需要这样做。 请告诉我这种方式能不能支持?我该怎么办?

@liuhaoyang
Copy link
Member

Work2 设置成虚函数

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

2 participants