Using Attributes to Call Methods

后端 未结 3 1789
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 12:38

I have various individual methods which all need to perform the same functions before continuing on with their own implementation. Now I could implement these functions in each

3条回答
  •  萌比男神i
    2021-02-07 13:10

    You're right, it sounds a lot like AOP.
    What you're after sounds like compile time weaving? I.e. the attribute is turned into additional code by the compiler.
    You could look at how to implement this...
    Generating additional code through a custom attribute
    http://www.cs.columbia.edu/~eaddy/wicca/ &
    http://www.sharpcrafters.com/aop.net/compiletime-weaving
    all refer to tools and techniques for doing this.

    Or you could use an AOP framework. IMHO, you should look at AOP frameworks.

提交回复
热议问题