public static FixedTypeKeyHashTableRegistry Build(IReadOnlyList <IRegistration> registrations) { // ThreadStatic if (buildBuffer == null) { buildBuffer = new Dictionary <Type, IRegistration>(128); } buildBuffer.Clear(); foreach (var registration in registrations) { if (registration.InterfaceTypes?.Count > 0) { foreach (var interfaceType in registration.InterfaceTypes) { AddToBuildBuffer(buildBuffer, interfaceType, registration); } } else { AddToBuildBuffer(buildBuffer, registration.ImplementationType, registration); } } var hashTable = new FixedTypeKeyHashtable <IRegistration>(buildBuffer.ToArray()); return(new FixedTypeKeyHashTableRegistry(hashTable)); }
public static FixedTypeKeyHashTableRegistry Build(IReadOnlyList <IRegistration> registrations) { // ThreadStatic if (buildBuffer == null) { buildBuffer = new Dictionary <Type, IRegistration>(128); } buildBuffer.Clear(); foreach (var registration in registrations) { if (registration.InterfaceTypes is IReadOnlyList <Type> interfaceTypes) { // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < interfaceTypes.Count; i++) { AddToBuildBuffer(buildBuffer, interfaceTypes[i], registration); } // Mark the ImplementationType with a guard because we need to check if it exists later. if (!buildBuffer.ContainsKey(registration.ImplementationType)) { buildBuffer.Add(registration.ImplementationType, null); } } else { AddToBuildBuffer(buildBuffer, registration.ImplementationType, registration); } } var hashTable = new FixedTypeKeyHashtable <IRegistration>(buildBuffer.ToArray()); return(new FixedTypeKeyHashTableRegistry(hashTable)); }
FixedTypeKeyHashTableRegistry(FixedTypeKeyHashtable <IRegistration> hashTable) { this.hashTable = hashTable; }