in src/React.Core/TinyIoC/TinyIoC.cs [3419:3485]
private void AutoRegisterInternal(IEnumerable<Assembly> assemblies, DuplicateImplementationActions duplicateAction, Func<Type, bool> registrationPredicate)
{
lock (_AutoRegisterLock)
{
var types = assemblies.SelectMany(a => a.SafeGetTypes()).Where(t => !IsIgnoredType(t, registrationPredicate)).ToList();
var concreteTypes = types
.Where(type => type.IsClass() && (type.IsAbstract() == false) && (type != this.GetType() && (type.DeclaringType != this.GetType()) && (!type.IsGenericTypeDefinition())))
.ToList();
foreach (var type in concreteTypes)
{
try
{
RegisterInternal(type, string.Empty, GetDefaultObjectFactory(type, type));
}
#if PORTABLE || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6
catch (MemberAccessException)
#else
catch (MethodAccessException)
#endif
{
// Ignore methods we can't access - added for Silverlight
}
}
var abstractInterfaceTypes = from type in types
where ((type.IsInterface() || type.IsAbstract()) && (type.DeclaringType != this.GetType()) && (!type.IsGenericTypeDefinition()))
select type;
foreach (var type in abstractInterfaceTypes)
{
var localType = type;
var implementations = from implementationType in concreteTypes
where localType.IsAssignableFrom(implementationType)
select implementationType;
if (implementations.Skip(1).Any())
{
if (duplicateAction == DuplicateImplementationActions.Fail)
throw new TinyIoCAutoRegistrationException(type, implementations);
if (duplicateAction == DuplicateImplementationActions.RegisterMultiple)
{
RegisterMultiple(type, implementations);
}
}
var firstImplementation = implementations.FirstOrDefault();
if (firstImplementation != null)
{
try
{
RegisterInternal(type, string.Empty, GetDefaultObjectFactory(type, firstImplementation));
}
#if PORTABLE || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6
catch (MemberAccessException)
#else
catch (MethodAccessException)
#endif
{
// Ignore methods we can't access - added for Silverlight
}
}
}
}
}