1

I am using ServiceStack's IPlugin mechanism in combination with request and response filters defined by attributes on my Service implementations. The attribute based filters can have an int to define their priority.

When defining a global request/response filter, there doesn't seem to be a way to set up the order in which that executes compared to other global request/response filters.

For example, I'd like my execution timing plugin's filters to be the first request filter, and the last response filter, to capture the execution time of requests fully.

Is it possible to define priority of filter when adding on request/response filters via IPlugin.Register?

4

1 回答 1

1

我认为,实际上(我希望 Demis 会发表评论),有: IPlugin希望我们实施void Register(IAppHost apphost). AppHost 允许我们做

appHost.RequestFilters.Add(OnBeginRequest);
appHost.ResponseFilters.Add(OnEndRequest);

whereOnBeginRequestOnEndRequest是与所需委托匹配的方法。

如果我然后将IHasRequestFilterand添加IHasResponseFilter到我的IPlugin实现中,并更改方法名称以匹配(或调用它们;无论哪个),然后实现 Priority 以返回我选择的 int ,IHasRequestFilter Copy()然后IHasResponseFilter Copy()我认为我已经完成了;从插件注册的优先全局过滤器。

于 2013-07-08T12:19:11.803 回答