about summary refs log tree commit diff
path: root/LibMatrix/Extensions/ClassCollector.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-04 02:16:40 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-04 02:16:40 +0200
commit1d02d9d76d987b69ed08a252a3fa66f7d05a4cbc (patch)
tree27314b621fa27045dcb375da9df9fde374d3c69d /LibMatrix/Extensions/ClassCollector.cs
parentCode cleanup (diff)
downloadLibMatrix-1d02d9d76d987b69ed08a252a3fa66f7d05a4cbc.tar.xz
Clean up some extension functions
Diffstat (limited to 'LibMatrix/Extensions/ClassCollector.cs')
-rw-r--r--LibMatrix/Extensions/ClassCollector.cs22
1 files changed, 0 insertions, 22 deletions
diff --git a/LibMatrix/Extensions/ClassCollector.cs b/LibMatrix/Extensions/ClassCollector.cs
deleted file mode 100644
index f53850a..0000000
--- a/LibMatrix/Extensions/ClassCollector.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Reflection;
-
-namespace LibMatrix.Extensions;
-
-public class ClassCollector<T> where T : class {
-    static ClassCollector() {
-        if (!typeof(T).IsInterface)
-            throw new ArgumentException(
-                $"ClassCollector<T> must be used with an interface type. Passed type: {typeof(T).Name}");
-    }
-
-    public List<Type> ResolveFromAllAccessibleAssemblies() => AppDomain.CurrentDomain.GetAssemblies().SelectMany(ResolveFromAssembly).ToList();
-
-    public List<Type> ResolveFromObjectReference(object obj) => ResolveFromTypeReference(obj.GetType());
-
-    public List<Type> ResolveFromTypeReference(Type t) => Assembly.GetAssembly(t)?.GetReferencedAssemblies().SelectMany(ResolveFromAssemblyName).ToList() ?? new List<Type>();
-
-    public List<Type> ResolveFromAssemblyName(AssemblyName assemblyName) => ResolveFromAssembly(Assembly.Load(assemblyName));
-
-    public List<Type> ResolveFromAssembly(Assembly assembly) => assembly.GetTypes()
-        .Where(x => x is { IsClass: true, IsAbstract: false } && x.GetInterfaces().Contains(typeof(T))).ToList();
-}