c#触发诸如mvc actionfilters之类的pre和post方法调用 [英] c# trigger pre and post method calls like mvc actionfilters

查看:171
本文介绍了c#触发诸如mvc actionfilters之类的pre和post方法调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以在asp.net mvc中获得动作过滤器的功能,因此您可以在标准方法中调用和操纵动作参数,然后在方法调用之前和之后通过方法调用以更新/查看返回类型数据,但是这些动作是在标准c#类库中进行的类方法?

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?

推荐答案

这听起来很像面向方面的编程 PostSharp 是可以帮助您实现目标的工具示例。一个常见的例子是让类自动实现 INotifyPropertyChanged 很无聊或乏味,或者在方法调用之前和之后吐出一堆日志语句,而不必

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.

这篇关于c#触发诸如mvc actionfilters之类的pre和post方法调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆