You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB
C#

10 months ago
using System.Reflection;
10 months ago
namespace DS.Module.Core;
10 months ago
/// <summary>
/// 实体帮助类
/// </summary>
public static class EntityUtil
10 months ago
{
10 months ago
//获取实体类型
public static Type getEntity(string typeName)
{
var workPath = AppDomain.CurrentDomain.BaseDirectory;
string[] files = Directory.GetFiles(workPath, "DS.WMS.Core.dll", SearchOption.TopDirectoryOnly);
foreach (string file in files)
{
string ext = file.Substring(file.LastIndexOf("."));
if (ext != ".dll") continue;
try
{
Assembly asm = Assembly.LoadFile(file);
Type[] allTypes = asm.GetTypes();
foreach (Type t in allTypes)
{
if (t.Name.ToUpper() == typeName.ToUpper())
return t;
// if (t.IsSubclassOf(typeof(XXDataRecord)))
// {
// if (t.Name.ToUpper().IsSame(typeName.ToUpper()))
// return t;
// }
}
}
catch
{
return null;
}
}
return null;
}
10 months ago
}