diff --git a/src/Autofac/Core/Registration/ComponentRegistry.cs b/src/Autofac/Core/Registration/ComponentRegistry.cs index 8b60c03b0..4cf9ebd8d 100644 --- a/src/Autofac/Core/Registration/ComponentRegistry.cs +++ b/src/Autofac/Core/Registration/ComponentRegistry.cs @@ -55,17 +55,17 @@ public class ComponentRegistry : Disposable, IComponentRegistry /// /// External registration sources. /// - private readonly IList _dynamicRegistrationSources = new List(); + private readonly List _dynamicRegistrationSources = new List(); /// /// All registrations. /// - private readonly ICollection _registrations = new List(); + private readonly List _registrations = new List(); /// /// Keeps track of the status of registered services. /// - private readonly IDictionary _serviceInfo = new Dictionary(); + private readonly Dictionary _serviceInfo = new Dictionary(); private readonly ConcurrentDictionary> _decorators = new ConcurrentDictionary>(); @@ -168,12 +168,16 @@ public void Register(IComponentRegistration registration, bool preserveDefaults) private void UpdateInitialisedAdapters(IComponentRegistration registration) { - var adapterServices = _serviceInfo - .Where(si => si.Value.ShouldRecalculateAdaptersOn(registration)) - .Select(si => si.Key) - .ToArray(); + var adapterServices = new List(); + foreach (var serviceInfo in _serviceInfo) + { + if (serviceInfo.Value.ShouldRecalculateAdaptersOn(registration)) + { + adapterServices.Add(serviceInfo.Key); + } + } - if (adapterServices.Length == 0) + if (adapterServices.Count == 0) return; Debug.WriteLine(