public void UpdateFrom(InstanceLookupBeginningMessage e) { if (e == null) { throw new ArgumentNullException("e"); } var instanceLookup = e.InstanceLookup; ResolveOperation resolveOperation; LifetimeScope activationScope; Component component; if (!_resolveOperations.TryGetItem(instanceLookup.ResolveOperationId, out resolveOperation) || !_lifetimeScopes.TryGetItem(instanceLookup.ActivationScopeId, out activationScope) || !_components.TryGetItem(instanceLookup.ComponentId, out component)) { throw new InvalidOperationException("Instance lookup depends on an unknown item."); } InstanceLookup item; if (resolveOperation.RootInstanceLookup == null) { item = new InstanceLookup(instanceLookup.Id, resolveOperation, activationScope, component); resolveOperation.RootInstanceLookup = item; resolveOperation.InstanceLookupStack.Push(item); } else { var top = resolveOperation.InstanceLookupStack.Peek(); item = new InstanceLookup(instanceLookup.Id, resolveOperation, activationScope, component, top); top.DependencyLookups.Add(item); resolveOperation.InstanceLookupStack.Push(item); } _instanceLookups.Add(item); }
public void UpdateFrom(RegistrationSourceAddedMessage message) { _registrationSources.Add(new RegistrationSource( message.RegistrationSource.Id, TypeIdentifier.Parse(message.RegistrationSource.TypeAssemblyQualifiedName), FormatDescription(message.RegistrationSource.Description))); }
public void UpdateFrom(ComponentAddedMessage message) { if (message == null) { throw new ArgumentNullException("message"); } TypeData limitType; if (!_types.TryGetItem(message.Component.LimitTypeId, out limitType)) { throw new InvalidOperationException("The component depends on an unknown type."); } var component = new Component( message.Component.Id, limitType, message.Component.Services.Select(svc => { TypeData serviceType; if (!_types.TryGetItem(svc.ServiceTypeId, out serviceType)) { throw new InvalidOperationException("The service provides an unknown type."); } return(new Service(svc.Description, serviceType, svc.Key)); }), message.Component.Ownership, message.Component.Sharing, message.Component.Metadata, message.Component.Activator, message.Component.Lifetime, message.Component.TargetComponentId); _components.Add(component); }
public void UpdateFrom(TypeDiscoveredMessage message) { var typeModel = message.TypeModel; var typeData = new TypeData( typeModel.Id, TypeNameParser.ParseAssemblyQualifiedTypeName(typeModel.AssemblyQualifiedName), typeModel.IsDisposable); _typeData.Add(typeData); }
public void UpdateFrom(ResolveOperationBeginningMessage message) { LifetimeScope lifetimeScope; if (!_lifetimeScopes.TryGetItem(message.ResolveOperation.LifetimeScopeId, out lifetimeScope)) { throw new InvalidOperationException("Resolve operation beginning in an unknown lifetime scope."); } Thread thread; if (!_threads.TryGetItem(message.ResolveOperation.ThreadId, out thread)) { thread = new Thread(message.ResolveOperation.ThreadId); _threads.Add(thread); } ResolveOperation parent = null; if (thread.ResolveOperationStack.Count != 0) { parent = thread.ResolveOperationStack.Peek(); } MethodIdentifier callingMethod = null; if (message.ResolveOperation.CallingMethodName != null) { callingMethod = new MethodIdentifier(message.ResolveOperation.CallingMethodName, TypeIdentifier.Parse(message.ResolveOperation.CallingTypeAssemblyQualifiedName)); } var resolveOperation = new ResolveOperation(message.ResolveOperation.Id, lifetimeScope, thread, parent, callingMethod); if (parent != null) { parent.SubOperations.Add(resolveOperation); } _resolveOperations.Add(resolveOperation); thread.ResolveOperationStack.Push(resolveOperation); }
public void UpdateFrom(LifetimeScopeBeginningMessage message) { if (message == null) { throw new ArgumentNullException("message"); } LifetimeScope parent = null; if (message.LifetimeScope.ParentLifetimeScopeId != null) { _lifetimeScopes.TryGetItem(message.LifetimeScope.ParentLifetimeScopeId, out parent); } var lifetimeScope = new LifetimeScope(message.LifetimeScope.Id, TagFor(message.LifetimeScope), parent); _lifetimeScopes.Add(lifetimeScope); if (parent != null) { parent.ActiveChildren.Add(lifetimeScope); } }