Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
765 B
5
Indexable
Never
public void CacheAssemblies()
{
    if (_assemblies == null)
    {
        _assemblies = AppDomain.CurrentDomain.GetAssemblies();
    }

    if (_types == null)
    {
        List<Type> typesList = new List<Type>();

        foreach (var assembly in _assemblies)
        {
            try
            {
                typesList.AddRange(assembly.GetTypes());
            }
            catch (ReflectionTypeLoadException e)
            {
                // Log or print the loader exceptions
                foreach (Exception loaderException in e.LoaderExceptions)
                {
                    Console.WriteLine(loaderException.Message);
                }
            }
        }

        _types = typesList.ToArray();
    }
}