Update InstanceFactory

This commit is contained in:
sunkaixuan
2023-11-01 13:09:06 +08:00
parent 6558991929
commit 0946f824c0

View File

@@ -6,13 +6,14 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SqlSugar namespace SqlSugar
{ {
public class InstanceFactory public class InstanceFactory
{ {
static Assembly assembly = Assembly.GetExecutingAssembly(); static Assembly assembly = Assembly.GetExecutingAssembly();
static Dictionary<string, Type> typeCache = new Dictionary<string, Type>(); static Dictionary<string, Type> typeCache = new Dictionary<string, Type>();
private static string _CustomDllName = ""; private static string _CustomDllName = "";
private static List<string> CustomDlls = new List<string>(); private static List<string> CustomDlls = new List<string>();
public static Assembly[] CustomAssemblies = new Assembly[]{};
public static string CustomDllName { public static string CustomDllName {
get { return _CustomDllName; } get { return _CustomDllName; }
set set
@@ -637,6 +638,10 @@ namespace SqlSugar
var newAssembly = new ReflectionInoCacheService().GetOrCreate<Assembly>(key, () => { var newAssembly = new ReflectionInoCacheService().GetOrCreate<Assembly>(key, () => {
try try
{ {
if (CustomAssemblies?.Any(it => it.FullName.StartsWith(customDllName))==true)
{
return CustomAssemblies?.First(it => it.FullName.StartsWith(customDllName));
}
var path = Assembly.GetExecutingAssembly().Location; var path = Assembly.GetExecutingAssembly().Location;
if (path.HasValue()) if (path.HasValue())
{ {
@@ -692,6 +697,10 @@ namespace SqlSugar
var newAssembly = new ReflectionInoCacheService().GetOrCreate<Assembly>(key, () => { var newAssembly = new ReflectionInoCacheService().GetOrCreate<Assembly>(key, () => {
try try
{ {
if (CustomAssemblies?.Any(it => it.FullName.StartsWith(customDllName)) == true)
{
return CustomAssemblies?.First(it => it.FullName.StartsWith(customDllName));
}
var path = Assembly.GetExecutingAssembly().Location; var path = Assembly.GetExecutingAssembly().Location;
if (path.HasValue()) if (path.HasValue())
{ {