Created
April 11, 2012 15:43
-
-
Save DalSoft/2360124 to your computer and use it in GitHub Desktop.
MVC – Get RavenDB up and running in 5 minutes using Ninject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Ninject; | |
using Ninject.Modules; | |
using Ninject.Web.Common; | |
using Raven.Client; | |
using Raven.Client.Embedded; | |
using Raven.Database.Server; | |
namespace RavenDBInFiveMinutes | |
{ | |
public class RavenDBNinjectModule : NinjectModule | |
{ | |
public override void Load() | |
{ | |
Bind<IDocumentStore>() | |
.ToMethod(context => | |
{ | |
NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080); | |
var documentStore = new EmbeddableDocumentStore { DataDirectory = "App_Data", UseEmbeddedHttpServer = true, }; | |
return documentStore.Initialize(); | |
}) | |
.InSingletonScope(); | |
Bind<IDocumentSession>().ToMethod(context => context.Kernel.Get<IDocumentStore>().OpenSession()).InRequestScope(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment