Skip to content

Instantly share code, notes, and snippets.

@tathamoddie
Created July 22, 2010 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tathamoddie/485586 to your computer and use it in GitHub Desktop.
Save tathamoddie/485586 to your computer and use it in GitHub Desktop.
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