/// <summary> /// Register all services /// </summary> /// <param name="registrar">Registrar used for the registration</param> public void Register(IContainerRegistrar registrar) { registrar.RegisterService(x => _store.OpenSession(), Lifetime.Scoped); registrar.RegisterConcrete<UowAdapter>(Lifetime.Scoped); //registrar.RegisterService(x => new UowAdapter(x.Resolve<IDocumentSession>(), _observer), Lifetime.Scoped); registrar.RegisterInstance(typeof (IUnitOfWorkObserver), _observerAdapter); registrar.RegisterInstance(typeof (IUnitOfWorkAdapter), this); }
/// <summary> /// Use Griffin.Container to execute the queries /// </summary> /// <param name="registrar">Your registrar</param> /// <param name="lifetime">The lifetime that the dispatcher should get.</param> public static void DispatchQueries(this IContainerRegistrar registrar, Lifetime lifetime) { if (registrar == null) { throw new ArgumentNullException("registrar"); } registrar.RegisterService <Queries.IQueryDispatcher>(x => new QueryDispatcher(x), lifetime); }
public override void RegisterService <TService>(Func <IScopedServiceLocator, TService> factoryMethod) { _containerRegistrar.RegisterService(x => factoryMethod(new ServiceLocatorAdapter(x)), Lifetime.Scoped); }
// this is the single method defined by the LoadEventListener interface /*public override void OnLoad(LoadEvent theEvent, LoadType loadType) { var type = Type.GetType(theEvent.EntityClassName); //_fluentConfig.Mappings(m => m.FluentMappings.) if (null == theEvent.InstanceToLoad) { theEvent.InstanceToLoad = ServiceResolver.Current.Resolve(type); } }*/ #region IContainerModule Members /// <summary> /// Register all services /// </summary> /// <param name="registrar">Registrar used for the registration</param> public void Register(IContainerRegistrar registrar) { registrar.RegisterService<ISession>(x=> _sessionFactory.OpenSession(), Lifetime.Scoped); registrar.RegisterService<IUnitOfWork>(x => new NhibernateUow(x.Resolve<ISession>()), Lifetime.Scoped); }