I'm registering the SitecoreService with Windsor as follows:
Component.For<ISitecoreService>().ImplementedBy<SitecoreService>().LifestyleTransient()
.DependsOn(Dependency.OnValue("databaseName","web"))
which works fine.
However, it means that the SitecoreService will always be looking at the same database (in this case web). Really I want to vary this according to the context of the request, so that when in Editing mode I'm accessing the master db, when on the front end I access master etc.
I guess I could wrap the SitecoreService with my own class that implements a parameterless constructor which uses the Sitecore.Context to decide which database name to use. I'd then register this as so:
Component.For<ISitecoreService>().ImplementedBy<MySitecoreService>().LifestylePerWebRequest()
But can anyone think of a better way of doing it?
Cheers,
Tom