Esempio n. 1
0
        public void DeactivateCommandShouldDeactivateItemWithLogAndPerRequest()
        {
            var dispatcher = new Dispatcher <ICommand>();
            var sh         = new StudentEnrollmentHandlers();
            var ch         = new CommonCommandHandlers();
            var lifeTime   = new LifeTime();

            Func <StudentRepository> studentRepositoryFactory = () => new StudentRepository();
            Func <ClassRepository>   classRepositoryFactory   = () => new ClassRepository();

            Action <StudentEnrollCommand> studentEnrollPipeline
                = x => ch.Log(x, next => sh.Enroll(lifeTime.PerThread(studentRepositoryFactory),
                                                   lifeTime.PerThread(classRepositoryFactory), next));

            dispatcher.Subscribe(studentEnrollPipeline);

            dispatcher.Dispatch(new StudentEnrollCommand(1, 2, DateTime.Now, DateTime.Now.AddMonths(6)));

            lifeTime.Dispose();
        }
Esempio n. 2
0
 public void Dispose()
 {
     _lifeTime.Dispose();
 }