Great fluent interface sample: the fluent repeater
I'm not that much a fan of fluent interfaces, but in some cases they are well fit.
A great example is the fluent repeater created by Adrian Aisemberg. It's also a good example if you don't know what a fluent interface is.
Here is sample code that uses it:
Repeat.Call<string>(Save).WithParameters("myfile.txt").UntilSucceeds.Start(10);
Repeat.Call(Ping).PauseBetweenCalls(2000).Start(100);
Some more:
Repeat.Call(Open).InBackgroundThread.At(ThreadPriority.Lowest).
OnSuccessCall(Opened).OnExceptionCall(Failed).Start();
This could be written in the following way using a non fluent interface:
Repeater repeater = new Repeater();
repeater.Method = Open;
repeater.InBackgroundThread = true;
repeater.ThreadPriority = ThreadPriority.Lowest;
repeater.Success += Opened;
repeater.Exception += Failed;
repeater.Start();
Which version do you prefer?