public static IEnumerable<Type> GetAccessibleTypes(this Assembly assembly)
{
try
{
#if NET40
return assembly.GetTypes();
#else
return assembly.DefinedTypes.Select(t => t.AsType());
#endif
}
catch (ReflectionTypeLoadException ex)
{
// The exception is thrown if some types cannot be loaded in partial trust.
// For our purposes we just want to get the types that are loaded, which are
// provided in the Types property of the exception.
return ex.Types.Where(t => t != null);
}
}
Quali sono le differenze tra assembly.GetTypes()
e assembly.DefinedTypes.Select(t => t.AsType())
?
Codice originale: link