The Helper Trinity is a set of helper classes applicable to most any .NET application. Using the classes in this library, you can much more easily validate arguments, raise events, and throw exceptions.
C# F# Batchfile
Latest commit ba17456 Aug 20, 2016 @kentcb Add AppVeyor config.
Permalink
Failed to load latest commit information.
.nuget Fix build. Jan 31, 2016
Art Fix logo. Jan 31, 2016
Doc What even is this change, git? Aug 6, 2016
Src netstandard support. Aug 16, 2016
.gitattributes Setting auto newline handling. Jan 11, 2015
.gitignore netstandard support. Aug 16, 2016
LICENSE netstandard support. Aug 16, 2016
README.md Add AppVeyor badge. Aug 18, 2016
appveyor.yml Add AppVeyor config. Aug 20, 2016
build.bat Fix build. Jan 31, 2016
build.fsx netstandard support. Aug 16, 2016

README.md

Logo

The Helper Trinity

Build status

What?

The Helper Trinity is a set of helper classes applicable to most any .NET application. Using the classes in this library, you can much more easily validate arguments, raise events, and throw exceptions.

Why?

Writing code to check arguments, raise events, and throw exceptions is mundane and error-prone. The Helper Trinity alleviates you of the need to write such code over and over again.

Where?

The easiest way to get The Helper Trinity is to install via NuGet:

Install-Package HelperTrinity

How?

public string GetContent(Uri uri, ContentFormat format)
{
    // validate arguments
    uri.AssertNotNull("uri");
    format.AssertEnumMember("format");

    // validate environment
    _exceptionHelper.ResolveAndThrowIf(!ConnectedToInternet, "NotConnected");

    // raise an event
    GettingContent.Raise(this, EventArgs.Empty);

    try
    {
        // get and return the content
        ...
    }
    catch (WebException ex)
    {
        // throw a more appropriate exception
        throw _exceptionHelper.Resolve("InvalidState", ex);
    }
} 

public event EventHandler<EventArgs> GettingContent;

private static readonly ExceptionHelper _exceptionHelper = new ExceptionHelper(typeof(MyType));

Please see the documentation for more details.

Who?

The Helper Trinity is created and maintained by Kent Boogaart. Issues and pull requests are welcome.

Primary Features

  • Easily check arguments and throw the appropriate exception type where expectations are not met
  • Easily raise events in a thread-safe manner
  • Easily throw exceptions and maintain exception messages in a centralized location
  • Includes extension methods to make argument checking and event raising even simpler
  • Support for checking generic arguments
  • Built with performance in mind
  • Extensively unit tested
  • Portable Class Library that targets many platforms