Re: Get current action method (MethodInfo) in Monorail

4 views
Skip to first unread message

John Simons

unread,
Nov 3, 2009, 10:42:07 PM11/3/09
to castle-pro...@googlegroups.com
Arthur, the monorail framewrk already has something that does what you want, is called Filters have a look at http://www.castleproject.org/monorail/documentation/trunk/usersguide/filters.html

Cheers John

On 03/11/2009, at 8:38 PM, Artur Dorochowicz <arturdor...@gmail.com> wrote:


Hello,

Is there a way to grab the method of current action in Monorail? I'm
thinking about MethodInfo object for the method or actually attributes
of the method.

I'm trying to do some logging before and after the action, they need
to be action specific. I thought about adding attributes on the method
and then reading them in some kind of Monorail filter, something like
this:

public class MyController : Controller
{
[LogOnBeforeAction("log message")]
[LogOnAfterAction("another log message")]
public void MyAction() {}
}

I have seen the article here: http://randomcode.net.nz/2008/03/03/adding-action-filters-to-monorail-controllers/
about adding action filters, but is actually flawed - it won't work
correctly when there are multiple overloads of an action.

Regards

Artur




__________________________________________________________________________________
Get more done like never before with Yahoo!7 Mail.
Learn more: http://au.overview.mail.yahoo.com/

Artur Dorochowicz

unread,
Nov 4, 2009, 2:48:41 PM11/4/09
to Castle Project Users

John,

I'm well aware of filters, but I just could not find a way to do what
I want with a filter.
I need to have logging specific for a method (e.g. different message
on GET request and on POST request, where actual method has same name,
but different arguments).

Anyway, as a workaround, I went more hardcore way and implemented this
idea through Windsor interceptor. I just don't like how I'm always
reading attributes on each invocation - will need to figure out how to
cache them. And also it would be nice to have some kind of exception
when decorated method is not virtual, but that is a different topic...

John, if you have some specific approach in mind for how to solve my
issue with MR filter, I would still very much like to hear it.

Thanks


Artur


On 4 Lis, 04:42, John Simons <johnsimons...@yahoo.com.au> wrote:
> Arthur, the monorail framewrk already has something that does what you want, is called Filters have a look athttp://www.castleproject.org/monorail/documentation/trunk/usersguide/...
>
> Cheers John
>
> On 03/11/2009, at 8:38 PM, Artur Dorochowicz <arturdorochow...@gmail.com> wrote:
>
> Hello,
>
> Is there a way to grab the method of current action in Monorail? I'm
> thinking about MethodInfo object for the method or actually attributes
> of the method.
>
> I'm trying to do some logging before and after the action, they need
> to be action specific. I thought about adding attributes on the method
> and then reading them in some kind of Monorail filter, something like
> this:
>
> public class MyController : Controller
> {
>   [LogOnBeforeAction("log message")]
>   [LogOnAfterAction("another log message")]
>   public void MyAction() {}
>
> }
>
> I have seen the article here:http://randomcode.net.nz/2008/03/03/adding-action-filters-to-monorail...

Ken Egozi

unread,
Nov 5, 2009, 2:21:49 AM11/5/09
to castle-pro...@googlegroups.com
your filter can look into the context.Request.Method
--
Ken Egozi.
http://www.kenegozi.com/blog
http://www.delver.com
http://www.musicglue.com
http://www.castleproject.org
http://www.idcc.co.il - הכנס הקהילתי הראשון למפתחי דוטנט - בואו בהמוניכם
Reply all
Reply to author
Forward
0 new messages