Introduction
These utility classes are piece of code I gathered from internet the last years. And I'm sure you'll find classes you'll use everyday here.
My goal is not to create a library, but just to gather cool piece of code at the same place so people can use them by copy pasting, without any dependencies.
If that's not already the case, I highly recommend you to gather cool piece of code you see on the web and having your personal framework correctly saved in a code repository somewhere. It will save you lots of time.
Some of you will tell that you don't have to reinvent the weel, and that's right.
But the point is that sometimes you have very specific and simple (but not easy) tasks to do and don't want the burden of yet another library. Moreover you are the most likely person who will want to reuse these classes later : you already know where to find them, how they behave, what pitfalls they have, and what you learnt by using them.
I've kept original comments in the code, so sometimes, you will be able to find the original author.
I want to thanks people who shared these classes on the net, and who saved me lots of time and money. The best thing I can do is to spread their work.
All unit tests or code snippet presented here pass.
- Introduction
- Content
- 11 useful classes
- LogonUser : how to impersonate a user, the easy way
- PathUtil : how to get a relative path from an absolute folder
- LambdaExtensions : extension methods to extract a property name from an expression.
- NotifyPropertyChangedBase : a concrete use case of LambdaExtensions.
- DisposableWrapperExtension : how to dispose effectively a WCF CommunicationObject
- EnumExtensions : How to easily manipulate a flag enum.
- ThreadSafeDictionary : how to add an item atomatically, the easy way
- BlockingStream : how to easily mock a client/server communication with a single Stream.
- WeakCollectionChangedListener : how to stop memory leakage when a listener have shorter life span than the listened object.
- WeakObservableCollection : a concrete use case, a wrapper around the listened object and owned by the listener.
- AssertEx : A class to make your tests readable.
- Conclusion : what utility class do you own and use frequently ?
Read more: Codeproject
0 comments:
Post a Comment