Skip to content

Instantly share code, notes, and snippets.

@uluhonolulu
Created August 13, 2012 06:58
Show Gist options
  • Save uluhonolulu/3337554 to your computer and use it in GitHub Desktop.
Save uluhonolulu/3337554 to your computer and use it in GitHub Desktop.
StructureMap syntax example
ObjectFactory.Initialize(x =>
{
// ISessionFactory is expensive to initialize, so create it as a singleton.
x.For<ISessionFactory>()
.Singleton()
.Use(CreateSessionFactory());
// Cache each ISession per web request. Remember to dispose this!
x.For<ISession>()
.HttpContextScoped()
.Use(context => context.GetInstance<ISessionFactory>().OpenSession());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment