void AttachToLifetimeScope(ILifetimeScope lifetimeScope, ILifetimeScope parent = null)
        {
            var lifetimeScopeModel = _modelMapper.GetLifetimeScopeModel(lifetimeScope, parent);
            var message = new LifetimeScopeBeginningMessage(lifetimeScopeModel);
            Send(message);

            lifetimeScope.CurrentScopeEnding += (s, e) =>
            {
                Send(new LifetimeScopeEndingMessage(lifetimeScopeModel.Id));
                _modelMapper.IdTracker.ForgetId(lifetimeScope);
            };

            lifetimeScope.ChildLifetimeScopeBeginning += (s, e) => AttachToLifetimeScope(e.LifetimeScope, lifetimeScope);
            lifetimeScope.ResolveOperationBeginning += (s, e) => AttachToResolveOperation(e.ResolveOperation, lifetimeScopeModel);
        }
 public void SetUp()
 {
     _fixture = new ModuleTestHarness();
     _profilerConnectedMessage = _fixture.GetSingleMessageOrDefault<ProfilerConnectedMessage>();
     _rootScopeBeginningMessage = _fixture.GetSingleMessageOrDefault<LifetimeScopeBeginningMessage>();
 }
 public void SetUp()
 {
     _fixture = new ModuleTestHarness();
     _fixture.ClearMessages();
     _lifetimeScope = _fixture.Container.BeginLifetimeScope();
     _lifetimeScope.Dispose();
     _lifetimeScopeBeginningMessage = _fixture.GetSingleMessageOrDefault<LifetimeScopeBeginningMessage>();
     _lifetimeScopeEndingMessage = _fixture.GetSingleMessageOrDefault<LifetimeScopeEndingMessage>();
 }