This commit is contained in:
CortexCore
2023-06-05 16:25:06 +08:00
parent 9027120bb8
commit 4565ff2e35
2947 changed files with 0 additions and 0 deletions

41
Core/Sharp/BITSharp.cs Normal file
View File

@@ -0,0 +1,41 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Reflection;
using System.IO;
namespace BITKit
{
public class BITSharp
{
private static readonly ConcurrentDictionary<string, Type> Dictionary = new();
static Assembly[] assemblies;
public static bool TryGetTypeFromFullName(string fullClassName,out Type type)
{
type = GetTypeFromFullName(fullClassName);
return type is not null ? true : false;
}
public static Type GetTypeFromFullName(string fullClassName)
{
return Dictionary.GetOrAdd(fullClassName, SearchType);
}
static Type SearchType(string fullName)
{
assemblies = assemblies??AppDomain.CurrentDomain.GetAssemblies();
foreach (var assembly in assemblies)
{
var type = assembly.GetType(fullName,false);
if (type is not null)
{
return type;
}
else
{
continue;
}
}
return null;
}
}
}