public LifetimeScopeBeginningMessage(LifetimeScopeModel lifetimeScope) { if (lifetimeScope == null) throw new ArgumentNullException("lifetimeScope"); _lifetimeScope = lifetimeScope; }
void AttachToResolveOperation(IResolveOperation resolveOperation, LifetimeScopeModel lifetimeScope) { var resolveOperationModel = _modelMapper.GetResolveOperationModel(resolveOperation, lifetimeScope, new StackTrace()); Send(new ResolveOperationBeginningMessage(resolveOperationModel)); resolveOperation.CurrentOperationEnding += (s, e) => { var message = e.Exception != null ? new ResolveOperationEndingMessage(resolveOperationModel.Id, e.Exception.GetType().AssemblyQualifiedName, e.Exception.Message) : new ResolveOperationEndingMessage(resolveOperationModel.Id); Send(message); }; resolveOperation.InstanceLookupBeginning += (s, e) => AttachToInstanceLookup(e.InstanceLookup, resolveOperationModel); }
public ResolveOperationModel GetResolveOperationModel(IResolveOperation resolveOperation, LifetimeScopeModel lifetimeScope, StackTrace callingStackTrace) { string locationTypeAssemblyQualifiedName = null, locationMethodName = null; var frames = callingStackTrace.GetFrames(); if (frames != null) { var lastUserCode = FindResolveCall(frames); if (lastUserCode != null) { locationMethodName = lastUserCode.Name; locationTypeAssemblyQualifiedName = lastUserCode.DeclaringType.AssemblyQualifiedName; } } return new ResolveOperationModel(NewId(), lifetimeScope.Id, GetThreadId(Thread.CurrentThread), locationTypeAssemblyQualifiedName, locationMethodName); }