private object ResolveInstance(ContainerEntry entry) { switch (entry.Lifetime) { case Lifetime.Singleton: return(entry.Instance); case Lifetime.None: return(entry.FactoryMethod(this)); default: throw new ArgumentOutOfRangeException(); } }
private ContainerEntry GetOrCreateEntry(Type service, string name) { var entry = GetEntry(service, name); if (entry == null) { entry = new ContainerEntry(this) { ServiceType = service, Name = name }; entries.Add(entry); } else { throw new InvalidOperationException($"An entry of type {service.FullName} was already registered with the name {name}."); } return(entry); }