NCommon without ServiceLocator

Jun 25, 2013 at 3:02 PM
We try to use NCommon for our project but we have a several composition root. Therefore we can't to define a global ServiceLocator. I 've found that It's possible to override UnitOfWorkScope, TransactionManager and LinqToSqlRepository to replace ServiceLocator.Current on IUnityContainer. But LinqToSqlRepository have a bad dependency in constructor, although there is a check ServiceLocator.Current !=null but It'll have risk that somebody set one. Can u enter virtual method in LinqToSqlRepository for this code:
            if (ServiceLocator.Current == null)

            var sessions = ServiceLocator.Current.GetAllInstances<ILinqToSqlSession>();
            if (sessions != null && sessions.Count() > 0)
                _privateSession = sessions.FirstOrDefault();