Browse Source

Removing a bunch of references to CoreUtils.TypeList to minimise reflection on startups

Kenric Nugteren 11 months ago
parent
commit
3668f2ee38

+ 7 - 14
InABox.Core/CoreUtils.cs

@@ -211,20 +211,10 @@ namespace InABox.Core
 
         public static void CheckLicensing()
         {
-            var entities = TypeList(
-                AppDomain.CurrentDomain.GetAssemblies(),
-                myType =>
-                    myType.IsClass
-                    && !myType.IsAbstract
-                    && !myType.IsGenericType
-                    && myType.IsSubclassOf(typeof(Entity))
-            );
-
+            var entities = Entities.Where(x => x.IsClass && !x.IsGenericType && x.IsSubclassOf(typeof(Entity)));
             foreach (var entity in entities)
             {
-                var lic = entity.GetInterfaces()
-                    .FirstOrDefault(x => x.IsConstructedGenericType && x.GetGenericTypeDefinition() == typeof(ILicense<>));
-                if (lic == null)
+                if (!entity.HasInterface(typeof(ILicense<>)))
                     Logger.Send(LogType.Error, "", "License Configuration Error: " + entity.EntityName().Split('.').Last());
             }
         }
@@ -399,12 +389,12 @@ namespace InABox.Core
         /// </summary>
         /// <param name="Predicate"></param>
         /// <returns></returns>
-        public static IEnumerable<Type> TypeList(Func<Type, bool> Predicate)
+        public static List<Type> TypeList(Func<Type, bool> Predicate)
         {
             var result = new List<Type>();
             try
             {
-                foreach (var type in entities.Values.Where(x => x != null))
+                foreach (var type in entities.Values)
                     try
                     {
                         if (Predicate(type))
@@ -457,6 +447,9 @@ namespace InABox.Core
         /// <summary>
         ///     Returns a list of types present within the assemblies.
         /// </summary>
+        /// <remarks>
+        ///     Prefer, when possible, <see cref="TypeList(Func{Type, bool})"/>.
+        /// </remarks>
         /// <param name="assemblies"></param>
         /// <param name="Predicate"></param>
         /// <returns></returns>

+ 10 - 21
InABox.Core/DataModel/AutoDataModel.cs

@@ -49,22 +49,14 @@ namespace InABox.Core
 
             if (_allo2mtypes == null)
             {
-                _allo2mtypes = CoreUtils.TypeList(
-                    AppDomain.CurrentDomain.GetAssemblies(),
-                    x => x.GetInterfaces().Any(
-                        i => i.IsGenericType
-                             && (i.GetGenericTypeDefinition() == typeof(IOneToMany<>)
-                                 || i.GetGenericTypeDefinition() == typeof(IManyToMany<,>)))
-                ).ToArray();
-
-                IEnumerable<Type> maps = _allo2mtypes.Where(
-                    x => x.GetInterfaces().Any(
-                             i => i.IsGenericType
-                                  && i.GetGenericTypeDefinition() == typeof(IOneToMany<>)
-                                  && i.GenericTypeArguments.Contains(typeof(T)))
-                         && !typeof(ISkipLoad).IsAssignableFrom(x)).OrderBy(x => x.EntityName());
-                var childMethod = GetType().GetMethods().Where(x => string.Equals(x.Name, "AddChildTable") && x.IsGenericMethod).FirstOrDefault();
-                var lookupMethod = GetType().GetMethods().Where(x => string.Equals(x.Name, "AddLookupTable") && x.IsGenericMethod).FirstOrDefault();
+                _allo2mtypes = CoreUtils.Entities.Where(x => x.HasInterface(typeof(IOneToMany<>)) || x.HasInterface(typeof(IManyToMany<,>))).ToArray();
+
+                var maps = _allo2mtypes.Where(x =>
+                        x.GetInterfaceDefinition(typeof(IOneToMany<>))?.GenericTypeArguments[0] == typeof(T)
+                        && !x.HasInterface<ISkipLoad>())
+                    .OrderBy(x => x.EntityName());
+                var childMethod = GetType().GetMethods().Where(x => string.Equals(x.Name, nameof(AddChildTable)) && x.IsGenericMethod).FirstOrDefault();
+                var lookupMethod = GetType().GetMethods().Where(x => string.Equals(x.Name, nameof(AddLookupTable)) && x.IsGenericMethod).FirstOrDefault();
                 foreach (var map in maps)
                 {
                     var method = childMethod.MakeGenericMethod(typeof(T), map);
@@ -112,11 +104,8 @@ namespace InABox.Core
                     }
                 }
 
-                IEnumerable<Type> mapsLookup = _allo2mtypes.Where(
-                    x => x.GetInterfaces().Any(
-                        i => i.IsGenericType
-                             && i.GetGenericTypeDefinition() == typeof(IManyToMany<,>)
-                             && i.GenericTypeArguments.Contains(typeof(T)))).OrderBy(x => x.EntityName());
+                var mapsLookup = _allo2mtypes.Where(x => x.GetInterfaceDefinition(typeof(IManyToMany<,>))?.GenericTypeArguments.Contains(typeof(T)) == true)
+                    .OrderBy(x => x.EntityName());
                 foreach (var map in mapsLookup)
                 {
                     var method = childMethod.MakeGenericMethod(typeof(T), map);

+ 0 - 18
InABox.Core/DatabaseSchema/StandardProperty.cs

@@ -28,7 +28,6 @@ namespace InABox.Core
             HasEditor = false;
         }
 
-        [ComboLookupEditor(typeof(StandardPropertyClassLookups))]
         public string Class
         {
             get => _class.EntityName();
@@ -58,7 +57,6 @@ namespace InABox.Core
             }
         }
 
-        [ComboLookupEditor(typeof(PropertyTypeLookups))]
         public string Type
         {
             get => _type;
@@ -232,21 +230,5 @@ namespace InABox.Core
 
             _checkedExpressions = true;
         }
-
-        private class StandardPropertyClassLookups : LookupGenerator<object>
-        {
-            public StandardPropertyClassLookups(object[] items) : base(items)
-            {
-                var types = CoreUtils.TypeList(
-                    AppDomain.CurrentDomain.GetAssemblies(),
-                    myType =>
-                        myType.IsClass
-                        && !myType.IsAbstract
-                        && myType.IsSubclassOf(typeof(BaseEditor))
-                );
-                foreach (var type in types)
-                    AddValue(type.EntityName(), type.Name);
-            }
-        }
     }
 }

+ 15 - 42
InABox.Core/DigitalForms/DFUtils.cs

@@ -65,12 +65,7 @@ namespace InABox.Core
 
         public static List<Type> GetFieldTypes(bool includeObsolete = false)
         {
-            _fieldTypes ??= CoreUtils.TypeList(
-                AppDomain.CurrentDomain.GetAssemblies(),
-                x => x.IsClass
-                && !x.IsAbstract
-                && !x.IsGenericType
-                && x.GetInterfaces().Any(x => x == typeof(IDFLayoutFormField))).ToList();
+            _fieldTypes ??= CoreUtils.Entities.Where(x => x.IsClass && !x.IsGenericType && x.HasInterface<IDFLayoutFormField>()).ToList();
             return includeObsolete ? _fieldTypes : _fieldTypes.Where(x => !x.HasInterface<IDFLayoutObsoleteField>()).ToList();
         }
 
@@ -117,25 +112,22 @@ namespace InABox.Core
         {
             get
             {
-                _formInstanceTypes ??= CoreUtils.TypeList(
-                    AppDomain.CurrentDomain.GetAssemblies(),
-                    x => !x.IsAbstract && x.GetInterfaces().Contains(typeof(IDigitalFormInstance))
-                ).Select(x =>
-                {
-                    var inter = x.GetInterfaces()
-                        .Where(x => x.IsGenericType && x.GetGenericTypeDefinition().Equals(typeof(IDigitalFormInstance<>))).FirstOrDefault();
-                    if (inter != null)
+                _formInstanceTypes ??= CoreUtils.Entities.Where(x => x.HasInterface<IDigitalFormInstance>())
+                    .Select(x =>
                     {
-                        var link = inter.GenericTypeArguments[0];
-                        var entityLinkDef = link.GetSuperclassDefinition(typeof(EntityLink<>));
-                        if (entityLinkDef != null)
+                        var inter = x.GetInterfaceDefinition(typeof(IDigitalFormInstance<>));
+                        if (inter != null)
                         {
-                            var entityType = entityLinkDef.GenericTypeArguments[0];
-                            return new Tuple<string, Type, Type>(entityType.Name, x, entityType);
+                            var link = inter.GenericTypeArguments[0];
+                            var entityLinkDef = link.GetSuperclassDefinition(typeof(EntityLink<>));
+                            if (entityLinkDef != null)
+                            {
+                                var entityType = entityLinkDef.GenericTypeArguments[0];
+                                return new Tuple<string, Type, Type>(entityType.Name, x, entityType);
+                            }
                         }
-                    }
-                    return null;
-                }).Where(x => x != null).ToDictionary(x => x!.Item1, x => new Tuple<Type, Type>(x!.Item2, x!.Item3));
+                        return null;
+                    }).Where(x => x != null).ToDictionary(x => x!.Item1, x => new Tuple<Type, Type>(x!.Item2, x!.Item3));
                 return _formInstanceTypes;
             }
         }
@@ -153,23 +145,7 @@ namespace InABox.Core
             }
             return null;
         }
-
         
-        public static IEnumerable<Type> GetFormEntityTypes()
-        {
-            return FormInstanceTypes.Select(x => x.Value.Item2);
-        }
-
-        public static Type? GetFormEntityType(string appliesTo)
-        {
-            if (FormInstanceTypes.TryGetValue(appliesTo, out var result))
-            {
-                return result.Item2;
-            }
-            return null;
-        }
-        
-
         private static Dictionary<Type, IEntityFormUtils> _formUtils = new Dictionary<Type, IEntityFormUtils>();
 
         public static void AddFormUtils<TForm, TEntity, TEntityLink>(
@@ -247,10 +223,7 @@ namespace InABox.Core
         }
         public static Type? FormEntityType(string appliesTo)
         {
-            return CoreUtils.TypeList(
-                AppDomain.CurrentDomain.GetAssemblies(),
-                x => string.Equals(x.Name, appliesTo)
-            ).FirstOrDefault();
+            return CoreUtils.Entities.FirstOrDefault(x => string.Equals(x.Name, appliesTo));
         }
 
         public static Type FormEntityLinkType(Type TForm)

+ 1 - 4
InABox.Core/DigitalForms/Forms/DigitalFormCategoryLookups.cs

@@ -11,10 +11,7 @@ namespace InABox.Core
         {
             get
             {
-                _formTypes ??= CoreUtils.TypeList(
-                    AppDomain.CurrentDomain.GetAssemblies(),
-                    x => !x.IsAbstract && x.GetInterfaces().Contains(typeof(IDigitalForm)) // &&  !x.GetInterfaces().Contains(typeof(IQAInstance))
-                ).ToArray();
+                _formTypes ??= CoreUtils.Entities.Where(x => x.HasInterface<IDigitalForm>()).ToArray();
                 return _formTypes;
             }
         }

+ 1 - 7
InABox.Core/DigitalForms/Layouts/DFLayout.cs

@@ -100,13 +100,7 @@ namespace InABox.Core
         /// <returns>A type which is a <see cref="DFLayoutControl"/></returns>
         private Type? GetElementType(string typeName)
         {
-            _controls ??= CoreUtils.TypeList(
-                AppDomain.CurrentDomain.GetAssemblies(),
-                x => x.IsClass
-                    && !x.IsAbstract
-                    && !x.IsGenericType
-                    && typeof(DFLayoutControl).IsAssignableFrom(x)
-            ).ToDictionary(
+            _controls ??= CoreUtils.Entities.Where(x => x.IsClass && !x.IsGenericType && typeof(DFLayoutControl).IsAssignableFrom(x)).ToDictionary(
                 x => x.EntityName(),
                 x => x);
             return _controls.GetValueOrDefault(typeName);

+ 1 - 4
InABox.Core/DigitalForms/Layouts/Fields/DFLayoutFieldProperties.cs

@@ -107,10 +107,7 @@ namespace InABox.Core
                 var form = Items?.FirstOrDefault() as DigitalForm;
                 if (form != null)
                 {
-                    var type = CoreUtils.TypeList(
-                        AppDomain.CurrentDomain.GetAssemblies(),
-                        x => string.Equals(x.Name, form.AppliesTo)
-                    ).FirstOrDefault();
+                    var type = DFUtils.FormEntityType(form);
                     if (type != null)
                     {
                         var props = CoreUtils.PropertyList(type, x => true, true);

+ 3 - 8
InABox.Core/Imports/ImportFactory.cs

@@ -21,14 +21,9 @@ namespace InABox.Core
         
         private static IImportMappingGenerator? GetGenerator(Type type)
         {
-            _generators ??= CoreUtils.TypeList(
-                    AppDomain.CurrentDomain.GetAssemblies(),
-                    myType =>
-                        myType.IsClass
-                        && !myType.IsAbstract
-                        && !myType.IsGenericType
-                        && myType.HasInterface(typeof(IImportMappingGenerator<>))
-                ).ToDictionary(x => x.GetInterfaceDefinition(typeof(IImportMappingGenerator<>))!.GenericTypeArguments[0], x => x);
+            _generators ??= CoreUtils.Entities
+                .Where(x => x.IsClass && !x.IsGenericType && x.HasInterface(typeof(IImportMappingGenerator<>))) 
+                .ToDictionary(x => x.GetInterfaceDefinition(typeof(IImportMappingGenerator<>))!.GenericTypeArguments[0], x => x);
             if(_generators.TryGetValue(type, out var generatorType))
             {
                 return Activator.CreateInstance(generatorType) as IImportMappingGenerator;

+ 1 - 18
InABox.Core/Licensing/LicenseUtils.cs

@@ -240,24 +240,7 @@ namespace InABox.Core
         {
             var result = new Dictionary<Type, Type>();
 
-            var licenses = CoreUtils.TypeList(
-                AppDomain.CurrentDomain.GetAssemblies(),
-                myType =>
-                    myType.IsClass
-                    && !myType.IsAbstract
-                    && !myType.IsGenericType
-                    && myType.IsSubclassOf(typeof(LicenseToken))
-            );
-
-            var entities = CoreUtils.TypeList(
-                AppDomain.CurrentDomain.GetAssemblies(),
-                myType =>
-                    myType.IsClass
-                    && !myType.IsAbstract
-                    && !myType.IsGenericType
-                    && myType.IsSubclassOf(typeof(Entity))
-            );
-
+            var entities = CoreUtils.Entities.Where(x => x.IsClass && !x.IsGenericType && x.IsSubclassOf(typeof(Entity)));
             foreach (var entity in entities)
             {
                 var lic = entity.GetInterfaces()

+ 1 - 19
InABox.Core/Postable/PosterEngine.cs

@@ -49,24 +49,6 @@ namespace InABox.Core
     {
     }
 
-    internal static class PosterEngineUtils
-    {
-        private static Type[]? _posters;
-
-        public static Type GetPoster(Type TPoster)
-        {
-            _posters ??= CoreUtils.TypeList(
-                AppDomain.CurrentDomain.GetAssemblies(),
-                x => x.IsClass
-                    && !x.IsAbstract
-                    && !x.IsGenericType
-                    && x.HasInterface(typeof(IPoster<,>))
-            ).ToArray();
-            return _posters.Where(x => TPoster.IsAssignableFrom(x)).FirstOrDefault()
-                ?? throw new Exception($"No poster of type {TPoster}.");
-        }
-    }
-
     /// <summary>
     /// A base class for all <see cref="IPosterEngine{TPostable}"/>. A concrete instance of this will be loaded by
     /// <see cref="PosterUtils.Process{T}(IDataModel{T})"/>; a new instance is guaranteed to be created each time that method is called.
@@ -86,7 +68,7 @@ namespace InABox.Core
             Poster = CreatePoster();
         }
 
-        private static readonly Type? PosterType = PosterEngineUtils.GetPoster(typeof(TPoster));
+        private static readonly Type? PosterType = PosterUtils.GetPoster(typeof(TPoster));
 
         protected virtual TPoster CreatePoster()
         {

+ 7 - 6
InABox.Core/Postable/PosterUtils.cs

@@ -131,15 +131,16 @@ namespace InABox.Core
 
         public static Type[] GetPosters()
         {
-            _posters ??= CoreUtils.TypeList(
-                AppDomain.CurrentDomain.GetAssemblies(),
-                x => x.IsClass
-                    && !x.IsAbstract
-                    && !x.IsGenericType
-                    && x.HasInterface(typeof(IPoster<,>))).ToArray();
+            _posters ??= CoreUtils.Entities.Where(x => x.IsClass && !x.IsGenericType && x.HasInterface(typeof(IPoster<,>))).ToArray();
             return _posters;
         }
 
+        public static Type GetPoster(Type TPoster)
+        {
+            return GetPosters().Where(x => TPoster.IsAssignableFrom(x)).FirstOrDefault()
+                ?? throw new Exception($"No poster of type {TPoster}.");
+        }
+
         private static EngineType[] GetPosterEngines()
         {
             _posterEngines ??= CoreUtils.TypeList(

+ 3 - 9
InABox.Core/Security/Security.cs

@@ -26,11 +26,8 @@ namespace InABox.Core
 
                     var custom = Task.Run(() =>
                     {
-                        var tokens = CoreUtils.TypeList(
-                            AppDomain.CurrentDomain.GetAssemblies(),
-                            x => !x.IsAbstract && !x.IsGenericType &&
-                                 x.GetInterfaces().Any(i => i == typeof(ISecurityDescriptor))
-                        );
+                        var tokens = CoreUtils.Entities.Where(
+                            x => !x.IsGenericType && x.HasInterface<ISecurityDescriptor>());
                         foreach (var _class in tokens)
                         {
                             var token = (Activator.CreateInstance(_class) as ISecurityDescriptor)!;
@@ -40,10 +37,7 @@ namespace InABox.Core
 
                     var auto = Task.Run(() =>
                     {
-                        var tokens = CoreUtils.TypeList(
-                            AppDomain.CurrentDomain.GetAssemblies(),
-                            x => !x.IsAbstract && !x.IsGenericType && x.IsSubclassOf(typeof(Entity))
-                        );
+                        var tokens = CoreUtils.Entities.Where( x => !x.IsGenericType && x.IsSubclassOf(typeof(Entity))).ToArray();
                         var view = Task.Run(() =>
                         {
                             foreach (var _class in tokens)

+ 3 - 3
InABox.Database/DbFactory.cs

@@ -69,9 +69,9 @@ public static class DbFactory
         
         // Start the provider
         Provider.Types = Entities.Where(x =>
-            x.GetTypeInfo().IsClass
-            && !x.GetTypeInfo().IsGenericType
-            && x.GetTypeInfo().IsSubclassOf(typeof(Entity))
+            x.IsClass
+            && !x.IsGenericType
+            && x.IsSubclassOf(typeof(Entity))
         ).ToArray();
 
         Provider.OnLog += LogMessage;

+ 1 - 6
inabox.wpf/DigitalForms/Designer/DynamicFormDesignGrid.cs

@@ -1801,12 +1801,7 @@ namespace InABox.DynamicGrid
             if (_fieldControls == null)
             {
                 _fieldControls = new();
-                foreach (var controlType in CoreUtils.TypeList(
-                    AppDomain.CurrentDomain.GetAssemblies(),
-                    x => x.IsClass
-                        && !x.IsAbstract
-                        && !x.IsGenericType
-                        && x.IsAssignableTo(typeof(IDynamicFormFieldControl))))
+                foreach (var controlType in CoreUtils.Entities.Where(x => x.IsClass && !x.IsGenericType && x.HasInterface<IDynamicFormFieldControl>()))
                 {
                     var superDefinition = controlType.GetSuperclassDefinition(typeof(DynamicFormFieldControl<,,,>));
                     if (superDefinition != null)

+ 1 - 1
inabox.wpf/DigitalForms/DigitalFormGrid.cs

@@ -399,7 +399,7 @@ namespace InABox.DynamicGrid
                             variables.Add($"Form.{property.Name}");
                     }
                     
-                    if (!appliesTo.IsNullOrWhiteSpace() && DFUtils.GetFormEntityType(appliesTo) is Type entityType)
+                    if (!appliesTo.IsNullOrWhiteSpace() && DFUtils.FormEntityType(appliesTo) is Type entityType)
                     {
                         foreach(var property in DatabaseSchema.Properties(entityType))
                             variables.Add($"{entityType.EntityName().Split('.').Last()}.{property.Name}");

+ 1 - 3
inabox.wpf/DynamicGrid/DynamicDataGrid.cs

@@ -556,11 +556,9 @@ public class DynamicDataGrid<TEntity> : DynamicGrid<TEntity>, IDynamicDataGrid w
 
         using (new WaitCursor())
         {
-            var types = CoreUtils.TypeList(
-                AppDomain.CurrentDomain.GetAssemblies(),
+            var types = CoreUtils.Entities.Where(
                 x =>
                     x.IsClass
-                    && !x.IsAbstract
                     && !x.IsGenericType
                     && x.IsSubclassOf(typeof(Entity))
                     && !x.Equals(typeof(AuditTrail))

+ 17 - 44
inabox.wpf/DynamicGrid/DynamicGridUtils.cs

@@ -112,10 +112,7 @@ public static class DynamicGridUtils
 
     public static IEnumerable<Type> GetManyToManyTypes(Type type)
     {
-        _allm2mtypes ??= CoreUtils.TypeList(
-            AppDomain.CurrentDomain.GetAssemblies(),
-            x => x.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IManyToMany<,>))
-        );
+        _allm2mtypes ??= CoreUtils.Entities.Where(x => x.HasInterface(typeof(IManyToMany<,>))).ToArray();
         return _allm2mtypes.Where(x => x.GetInterfaces().Any(
             i => i.IsGenericType
             && i.GetGenericTypeDefinition() == typeof(IManyToMany<,>)
@@ -135,16 +132,11 @@ public static class DynamicGridUtils
             {
                 if (ClientFactory.IsSupported(map))
                 {
-                    _allm2mpages ??= CoreUtils.TypeList(
-                            AppDomain.CurrentDomain.GetAssemblies(),
+                    _allm2mpages ??= CoreUtils.Entities.Where(
                             x => x.IsClass
-                                 && !x.IsAbstract
                                  && !x.IsGenericType
-                                 && x.GetInterfaces().Any(
-                                     i => i.IsGenericType
-                                          && i.GetGenericTypeDefinition() == typeof(IDynamicManyToManyGrid<,>)
-                                 )
-                        );
+                                 && x.HasInterface(typeof(IDynamicManyToManyGrid<,>)))
+                        .ToArray();
 
                     var subtypes = _allm2mpages.Where(
                         x => x.GetInterfaces().Any(i =>
@@ -170,11 +162,9 @@ public static class DynamicGridUtils
 
     public static IEnumerable<Type> GetOneToManyTypes(Type type)
     {
-        _allo2mtypes ??= CoreUtils.TypeList(
-            AppDomain.CurrentDomain.GetAssemblies(),
-            x => x.GetInterfaces().Any(i =>
-                i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IOneToMany<>) && x.GetCustomAttribute<ObsoleteAttribute>() == null)
-        );
+        _allo2mtypes ??= CoreUtils.Entities.Where(
+            x => x.HasInterface(typeof(IOneToMany<>)) && !x.HasAttribute<ObsoleteAttribute>())
+            .ToArray();
         return _allo2mtypes
             .Where(x => x.GetInterfaces().Any(i =>
                 i.IsGenericType
@@ -196,17 +186,12 @@ public static class DynamicGridUtils
                 if (ClientFactory.IsSupported(map))
                 {
 
-                    _allo2mpages ??= CoreUtils.TypeList(
-                            AppDomain.CurrentDomain.GetAssemblies(),
+                    _allo2mpages ??= CoreUtils.Entities.Where(
                             x =>
                                 x.IsClass
-                                && !x.IsAbstract
                                 && !x.IsGenericType
-                                && x.GetInterfaces().Any(i =>
-                                    i.IsGenericType
-                                    && i.GetGenericTypeDefinition() == typeof(IDynamicOneToManyGrid<,>)
-                                )
-                        );
+                                && x.HasInterface(typeof(IDynamicOneToManyGrid<,>)))
+                        .ToArray();
 
                     var subtypes = _allo2mpages.Where(x => x.GetInterfaces().Any(
                             i => i.IsGenericType
@@ -236,16 +221,11 @@ public static class DynamicGridUtils
     {
         if (!_customeditorpages.TryGetValue(type, out var pageTypes))
         {
-            _allcepages ??= CoreUtils.TypeList(
-                    AppDomain.CurrentDomain.GetAssemblies(),
+            _allcepages ??= CoreUtils.Entities.Where(
                     x => x.IsClass
-                         && !x.IsAbstract
                          && !x.IsGenericType
-                         && x.GetInterfaces().Any(i =>
-                             i.IsGenericType
-                             && i.GetGenericTypeDefinition() == typeof(IDynamicCustomEditorPage<>)
-                         )
-                );
+                         && x.HasInterface(typeof(IDynamicCustomEditorPage<>)))
+                .ToArray();
 
             pageTypes = _allcepages.Where(x => x.GetInterfaces().Any(i =>
                 i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IDynamicCustomEditorPage<>) &&
@@ -279,16 +259,11 @@ public static class DynamicGridUtils
                             var editor = property.GetCustomAttributes().FirstOrDefault(x => x is BaseEditor);
                             if (editor == null || !(editor is NullEditor))
                             {
-                                _alleltypes ??= CoreUtils.TypeList(
-                                        AppDomain.CurrentDomain.GetAssemblies(),
+                                _alleltypes ??= CoreUtils.Entities.Where(
                                         x => x.IsClass
-                                             && !x.IsAbstract
                                              && !x.IsGenericType
-                                             && x.GetInterfaces().Any(i =>
-                                                 i.IsGenericType
-                                                 && i.GetGenericTypeDefinition() == typeof(IDynamicEnclosedListGrid<,>)
-                                             )
-                                    );
+                                             && x.HasInterface(typeof(IDynamicEnclosedListGrid<,>)))
+                                    .ToArray();
 
                                 var subtypes = _alleltypes.Where(
                                     x => x.GetInterfaces().Any(
@@ -449,11 +424,9 @@ public static class DynamicGridUtils
     {
         if (!_dynamicGrids.TryGetValue(gridType, out var grids))
         {
-            grids = CoreUtils.TypeList(
-                AppDomain.CurrentDomain.GetAssemblies(),
+            grids = CoreUtils.Entities.Where(
                 myType =>
                     myType.IsClass
-                    && !myType.IsAbstract
                     && !myType.IsGenericType
                     && myType.IsAssignableTo(typeof(IDynamicGrid))
                     && !myType.IsAssignableTo(typeof(ISpecificGrid))