C# methods decoration using lambda expressions(nextension.blogspot.com)
submitted by
Nextender(20) 4 years, 1 month ago
On regular basis several repeating code blocks appear in projects source code. Wouldn't it be great if we could just say: here is my method, do call within TCF block ("try - catch - finally" block) first time I need it, but I may require to call it with "try - catch" block only next time or with other catch block content (say I had logging there, but decided to remove or replace it for some special cases of this method call):
// Like this
return MyMethod1.TCF(ex => Log(ex), arg => DoSomeFinallyAction(arg))(arg);
|category: C#
|Views: 67
tags:
Expressions Lambda C# another
Everyones tags:
Your Tags: