PeanutButter is a collection of projects which provide useful bits of functionality that I've often had to re-use.
Quick links
This is by no means a comprehensive list of functionality that is available - it's just some of the things I use the most, that may be helpful to others.
Utilities
- Extension methods
- collections
- FindOrAdd for dictionaries
- And - fluent arrays, eg foo.And(new [ 1, 2, 3 ]);
- AsTextList and derivatives for dumping data neatly to the console or a textarea
- Trim() on a collection of strings
- JS-like methods (Map, Filter - working with array types)
- duck-typing
- wrap any object in a well-defined interface and have your data & methods forwarded
- works well on dictionaries too
- useful for converting your app configuration to a well-defined object to pass around
- can be used to "shield" a more complex type from a consumer only interested in a subset of the functionality
- objects
- deep equality testing
- reflection conveniences (eg o.Get<T>("PropertyName") / o.Set("PropertyName", "value")
- o.DeepClone<T>()
- .Stringify() to dump an object in "json-like" notation (good for logs / diagnostics)
- SlidingWindow: keep a running collection based on item count or max-age
- SingleItemCache: simple, easy way to implement localised caching for a value, eg an application setting which is queried a lot from a database
- Disposables to make life easier:
- AutoTempFile - deletes the temp file when disposed
- AutoTempFolder - deletes the temp folder and contents when disposed
- AutoLocker - locks the semaphore / mutex for the duration of the non-disposed lifetime
- AutoResetter - perform an action at instantiation, and undo it at disposal
- AutoTempEnvironmentVariable - set an environment variable for the duration of the non-disposed lifetime
- AutoBarrier - only exit the disposal block when all participants have joined
- CircularList - enumerate forever, cyclically, through a list
- Dictionaries!
- Test utilities
- EasyArgs
- parses commandlines to an interface, can be guided with attributes on the interface
- ServiceShell
- low-friction scaffolding for polling win32 services
- INI reader/writer with comment preservation