Created
July 22, 2010 04:58
-
-
Save tathamoddie/485586 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Test() | |
{ | |
new UnitOfWork() | |
.AddWork(SomeMethod, 123.5) | |
.AddWork(SomeOtherMethod, "hello", 123); | |
} | |
void SomeMethod(double something) | |
{ | |
} | |
void SomeOtherMethod(string arg1, int arg2) | |
{ | |
} | |
public class UnitOfWork | |
{ | |
public UnitOfWork AddWork(Action work) | |
{ | |
// Do something smart | |
return this; | |
} | |
public UnitOfWork AddWork<T1>(Action<T1> work, T1 arg1) | |
{ | |
return AddWork(() => work.Invoke(arg1)); | |
} | |
public UnitOfWork AddWork<T1, T2>(Action<T1, T2> work, T1 arg1, T2 arg2) | |
{ | |
return AddWork(() => work.Invoke(arg1, arg2)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment