Exemple #1
0
        public static IEnumerable <Type> FindDerivedTypes([NotNull] AppDomain currentDomain, [NotNull] Type baseType, Tristate classOnly)
        {
            List <Type> types = null;

            Assembly[] array = currentDomain.ArgumentNotNull().GetAssemblies();

            for (var assemblyCount = 0; assemblyCount < array.Length; assemblyCount++)
            {
                try
                {
                    Assembly assembly  = array[assemblyCount];
                    var      tempTypes = LoadDerivedTypes(assembly.DefinedTypes, baseType, classOnly).ToList();

                    if (tempTypes?.FastCount() > 0)
                    {
                        if (types is null)
                        {
                            types = tempTypes;
                        }
                        else
                        {
                            types.AddRange(tempTypes);
                        }
                    }
                }
                catch (ReflectionTypeLoadException reflectionEx)
                {
                    Trace.WriteLine(reflectionEx.GetAllMessages());
                }
            }

            return(types);
        }