Run a method before all methods of a class

前端 未结 8 2116
孤街浪徒
孤街浪徒 2020-12-06 15:51

Is it possible to do that in C# 3 or 4? Maybe with some reflection?

class Magic
{

    [RunBeforeAll]
    public void BaseMethod()
    {
    }

    //runs Ba         


        
8条回答
  •  时光取名叫无心
    2020-12-06 16:33

    What you want can be done with AOP - some links to .NET C# AOP frameworks:

    • http://www.postsharp.org/
    • http://www.castleproject.org/dynamicproxy/index.html
    • http://www.springframework.net/docs/1.2.0-M1/reference/html/aop.html

提交回复
热议问题