public bool TryGet(Type interfaceType, out IRegistration registration) { if (hashTable.TryGet(interfaceType, out registration)) { return(true); } // Auto falling back to collection from one if (interfaceType.IsGenericType) { // TODO: var genericType = interfaceType.GetGenericTypeDefinition(); if (genericType == typeof(IEnumerable <>) || genericType == typeof(IReadOnlyList <>)) { var elementType = interfaceType.GetGenericArguments()[0]; var collectionRegistration = new CollectionRegistration(elementType); // ReSharper disable once InconsistentlySynchronizedField if (hashTable.TryGet(elementType, out var elementRegistration)) { collectionRegistration.Add(elementRegistration); } registration = collectionRegistration; return(true); } } return(false); }
public bool TryGet(Type interfaceType, out IRegistration registration) { if (hashTable.TryGet(interfaceType, out registration)) { return(registration != null); } if (interfaceType.IsConstructedGenericType) { var genericType = interfaceType.GetGenericTypeDefinition(); return(TryFallbackSingleCollection(interfaceType, genericType, out registration)); } return(false); }