Giter Club home page Giter Club logo

thehelpertrinity's Introduction

The Helper Trinity

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 Kent.Boogaart.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 currently developed solely by Kent Boogaart.

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 all platforms

thehelpertrinity's People

Contributors

yazgoo avatar kentcb avatar braincrumbz avatar lambda125 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.