c# trigger pre and post method calls like mvc acti

2019-08-03 04:57发布

Is there a way to get the functionality of action filters in asp.net mvc where you can call and manipulate action parameters pre the method executing and post method call to update/view the return type data but in a standard c# class library class method?

1条回答
手持菜刀,她持情操
2楼-- · 2019-08-03 05:32

This sounds a lot like aspect-oriented programming. PostSharp is an example of a tool that can help you get there. A common example is to have a class auto-implement INotifyPropertyChanged, which is boring or tedious, or to spit out a bunch of logging statements before and after a method call, without having to manually write that instrumentation in code.

Hope that gets you on the right track.

查看更多
登录 后发表回答