GetCached(BLCustomer.GetAll, "GetAll");
where "GetAll" is session key.
How can I do something like this?
GetCached(BLCustomer.GetAll, BLCustomer.GetAll.ToString());
UPDATE:
other worlds I wanna to get the string "GetAll" (not names of customers, but the name of the method) from method name BLCustomer.GetAll().
I want to use something like this
GetCached(BLCustomer.GetSingle, BLCustomer.GetSingle.ToString());
instead of
GetCached(BLCustomer.GetSingle, "GetSingle");
to avoid hardcoding name of methods.
SIMPLE SOLUTION: (stolen from leppie below)
Simply remove the second parameter from your
GetCachedmethod:This assumes, that it will be called like this:
and not like this:
COMPLEX SOLUTION:
You can do it like this:
Call it like this:
This approach makes two assumptions:
voidand must not have any parameters.You can use this also for non static methods:
You can even change
GetCachedto the following to cleanup its API:For this to work, you need to make
GetMethodNamegeneric instead of usingdynamic:And then you can call it like this: