Monday, June 15, 2009

My.Utilities Class Library

Summary: Helper utilities library that some .NET developers may appreciate.

For several years, I have been compiling a library of utility/helper classes reused across multiple projects. You may recognize some of these classes if you read my published articles, but there are several classes that have not been released to the public, yet.

Here is a brief description of the most useful classes in the library (and there are more):
  • BaseForm
    I derive all my web form classes from this class. This classed extends the functionality of System.Web.UI.Page by offering many handy features, such as easy time localization (automatically converts time from GMT/UTC to local time on the client and vise versa; for additional information read It's About Time), invoking JavaScript pop-ups from code-behind, quick enabling/disabling/showing/hiding page controls, setting/getting session parameter in/from a cookie, retrieval of data values from form/query string, deep search for controls, and more.
  • AppProcess
    Loads a named assembly from a non-standard path (assuming that you specify alternate paths).
  • ExceptionInfo
    Generates formatted error messages for different type of exceptions based on various parameters and exception types, retrieves messages from inner exceptions and database error objects (for additional info, read Dissecting Error Messages).
  • Helper
    Okay, I agree: this is not a good name... Anyway, this class makes it easy to check for empty objects of different data types. For example, you can check for empty or null array in a single statement (if (Helper.IsEmpty(myArray)) instead of having to check for null first, and then for the number of elements in the array.
  • WindowsService
    Simplifies implementation of Windows services. Other classes in the same namespace (My.Utilities.Services) make it trivial to write periodic tasks (daily, weekly, etc) that Windows services normally perform (for additional info, see Implementing Windows services in Visual Studio 2008).
  • DataHelper
    Converts database values to standard .NET types, so you do not have to worry about special handling of DBNull values.
  • Name
    Makes formatting of people's names based on the available name parts easier, e.g. John F Kennedy, Jr; Kennedy, John F, Jr; John F Kennedy; Kennedy, John F; John Kennedy; Kennedy, John; etc.
To see the description of all classes in the library, download the help file:
This help file covers all classes, methods, properties, etc., and even offers a few samples.

If you are still interested, you can download the library project:
My.Utilities Class Library Project (Visual Studio 2008)
Just keep in mind that I started writing this library around 2001/2002, so some functionality could've been improved had the technology -- nullable types, generics, etc. -- been available at the time. Also, the general disclaimer applies: use at your own risk.

I hope this helps someone, but if you run into any issues, please let me know.

No comments: