.NET Core: attributes that execute before and after method

前端 未结 4 1966
余生分开走
余生分开走 2021-01-12 17:10

In Java, it is possible to use AspectJ for adding behavior before and after executing a method, using method annotations. Since C# Attributes seem to be very similar, I was

4条回答
  •  囚心锁ツ
    2021-01-12 17:39

    Just like with Java and AspectJ, you need separate AoP tooling to inject code like this in .NET.

    PostSharp is one such tool, probably the best known. I belive they have support for .NET core since version 5.

提交回复
热议问题