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); }
static string TagFor(LifetimeScopeModel lifetimeScope) { return(lifetimeScope.Tag == "System.Object" ? null : lifetimeScope.Tag); }
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)); }