Bootstrapping Goodness 0

Here’s some code from the BootStrapper that I’ve been rather happy with building WinForms apps lately:

public ApplicationContext Initialize() {

        this.container.Configure(c => c.AddRegistry<SomeStructureMapRegistry>());
        this.container.Inject(this.container);

        ApplicationSettings settings = new AppSettingsParser().Parse(this.appSettings);
        this.container.Inject(settings);

        this.attachErrorHandling();

        var context = this.container.GetInstance<AppContext>();
        return context;
    }

Of course, you use it something like this:

private static void Main() {

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        Application.Run(new BootStrapper(ConfigurationManager.AppSettings, new Container()).Initialize());
    }

Resharper Tip : To-do Explorer 1

Do you find your code riddled with

throw new NotImplementedException();

or

// TODO:

Did you know that Resharper provides support to find those elements quickly?

When using the Visual Studio keyboard mappings, you can bring up the To-do Explorer with [Ctrl+Alt+D] or click on the Resharper > Windows > To-do Explorer.

For futher tweaking, check out the “To-do Items” in the Resharper Options window. It provides full RegEx capability for creating your own patterns!



kick it on DotNetKicks.com

.NET Reading List 0

On the nightstand

  • Essential ASP.NET with Examples in C# (Onion)
  • Framework Design Guidelines (Cwalina, Abrams)
  • .NET Gotchas (Subramaniam)
  • Programming .NET Components (Lowy)

On the bookshelf

  • Must Read
  • Short-lived
  • Kindling

On the Wish List

  • Business Objects in C#
  • Business Objects in C# 2005

Next Page »