refactor: rewritten GetType in a more readable way
This commit is contained in:
parent
1ea1844677
commit
c20f210b29
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace Syntriax.Engine.Core.Factory;
|
namespace Syntriax.Engine.Core.Factory;
|
||||||
|
|
||||||
@ -24,11 +23,9 @@ public static class TypeFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Type GetType(string fullName)
|
public static Type GetType(string fullName)
|
||||||
{
|
=> AppDomain.CurrentDomain
|
||||||
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
.GetAssemblies()
|
||||||
if (assembly.GetTypes().FirstOrDefault(t => t.FullName?.CompareTo(fullName) == 0) is Type type)
|
.SelectMany(a => a.GetTypes())
|
||||||
return type;
|
.FirstOrDefault(t => t.FullName?.CompareTo(fullName) == 0)
|
||||||
|
?? throw new Exception($"Type {fullName} could not be found in the current domain.");
|
||||||
throw new Exception($"Type {fullName} could not be found in the current domain.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user