Open source update

ByMogens

Open source update

As part of daily work, little code snippets and useful bits crystallize and turn out to be so useful that it would be a shame not to share it with anyone.

Yesterday, two new small and focused projects were added to rebus-org: Owino and Swindler.

Owino

Owino is a NuGet package with OWIN extensions. At the moment, it has one single extension method: RegisterForDisposal, which is an extension method on IAppBuilder. You can use it like this:

public void Configuration(IAppBuilder app)
{
    // we're using Windsor
    var container = new WindsorContainer();

    // we're doing stuff
    // (...)

    // we ALWAYS dispose our IoC containers after use
    app.RegisterForDisposal(container);
}

which then ensures that the container is properly disposed when the application shuts down – no matter if the OWIN endpoint is hosted in-process, in an IIS, in a test, or somewhere else.

Swindler

Yesterday Jeremy Miller talked about having to juggle AppDomains in order to properly test code that relies on ConfigurationManager.

You don’t have to pull out the big gun to shoot that tiny bird though, because it IS possible to have the current AppDomain load another app.config – it just requires some tweaking of some private static fields in ConfigurationManager and some other places.

Swindler makes that part easy, because you can just do this:

[Test]
public void SomeTest()
{
    using (AppConfig.Use("my.custom.app.config"))
    {
        // ConfigurationManager will load app settings,
        // connection strings, and custom sections from
        // my.custom.app.config in here
    }
}

which then provides a way to actually test that you can pick up app settings, connection strings, and any custom configuration sections that you might have created.

Where to get it?

They’re both MIT-licensed and can be downloaded from the following places:

About the author

Mogens administrator

Author of Rebus

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.