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); }
bool TryFallbackSingleCollection(Type interfaceType, Type genericType, out IRegistration registration) { 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) && elementRegistration != null) { collectionRegistration.Add(elementRegistration); } registration = collectionRegistration; return(true); } registration = null; return(false); }