从 OpenRasta 中的接收处理程序外部获取反序列化实体
在 OpenRasta(版本 2.0.50727)中,如何从接收请求的处理程序外部获取反序列化实体的实例(在通过对象绑定传递之后)?具体一点;在发生异常的情况下,我希望 IOperationInterceptor 将 POST 实体返回给客户端,并添加一些错误信息,以便客户端可以更正信息并使用同一实体重新执行 POST 。
我查看了 IRequest.Entity
,但这看起来像是实体的“原始”版本,这不是我想要的。我还查看了 IOperation.Inputs.First().Member
(如在 IOperationInterceptor.BeforeExecute()
中收到的那样),但这看起来对于对象绑定器而不是我所追求的,即最终绑定和实例化的对象。
In OpenRasta (version 2.0.50727), how do I get to the instance of the deserialized entity (after being passed through object binding) from outside the handler that receives the request? To be specific; in the case of an exception, I want an IOperationInterceptor
to return the POSTed entity to the client, with some added error information, so the client can correct the information and re-do the POST with the same entity.
I've looked at IRequest.Entity
, but that looks like a "raw" version of the entity, which is not what I'm after. I've also looked at IOperation.Inputs.First().Member
(as received in IOperationInterceptor.BeforeExecute()
), but that too looks like something more useful for an object binder than for what I'm after, which is the finally bound and instantiated object.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现你可以像这样在 IOperationInterceptor.BeforeExecute 中重新构建对象:
我还没有测试这会产生什么样的开销以及是否可以访问已经构建的实例,但是这个似乎正在发挥作用。如果有人对如何做得更好有想法,请添加答案。在接受这个作为解决方案之前,我会先暂时不回答这个问题。
I figured out that you can re-build the object in
IOperationInterceptor.BeforeExecute
like so:I haven't tested what kind of overhead this incurs and if it's possible to get to the already built instance, but this seems to be working. If anyone has ideas on how to do it better, please add an answer. I'll leave the question unanswered a while before accepting this as the solution.