I may have found the Peanut Butter to my Jelly. Maybe not, but I accidentally stumbled upon a project called Palmer. This library lets one define an amount of time to do some sort of activity. Maybe a call that fails frequently, so you want to ping it many times before just giving up. I’m not using it in anything currently, but I’d like to some day.
I noticed that it uses some TimeSpans and I’ve been meaning to incorporate my pet project TempusReader into something of use. I combined the two and they worked just great together! I set up a tiny example like this, just to get going with them:
Obviously the example isn’t real world, but you get the point. The code is actually all Palmer, the only part that is TempusReader is the .InTime() extension method. Alternatively, I could have used other methods to specify the TimeSpan:
new Time("1 hr, 5 mins and 8 seconds") "50 milliseconds".InTime()
This takes a string and converts it to a TempusReader.Time object, which can be implicitly cast to a TimeSpan for use in the .For() method.
Both these projects are on NuGet (the current version of Palmer was giving me issues):
Install-Package Palmer -Version 0.1.4723.40614
Post Footer automatically generated by Add Post Footer Plugin for wordpress.