更新wtm

This commit is contained in:
zgf committed 2023-08-11 15:55:50 +08:00
1 parent f119665d29
commit 3467d4aa9d
60 files changed
+1932 -397

No files matched your search

+39 -1
View File
@@ -1,3 +1,4 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Distributed;
using NPOI.HSSF.Util;
using System;
@@ -21,7 +22,7 @@ namespace WalkingTec.Mvvm.Core
{
private static List<Assembly> _allAssemblies;
private static List<Type> _allModels;
public static string GetCurrentComma()
{
if (CultureInfo.CurrentUICulture.Name == "zh-cn")
@@ -96,6 +97,43 @@ namespace WalkingTec.Mvvm.Core
return _allAssemblies;
}
private static List<Type> _allModelTypes= new List<Type>();
public static List<Type> GetAllModels()
{
if (_allModels == null)
{
var modelAsms = Utils.GetAllAssembly();
var allTypes = new List<Type>();// 所有 DbSet<> 的泛型类型
// 获取所有 DbSet<T> 的泛型类型 T
foreach (var asm in modelAsms)
{
try
{
var dcModule = asm.GetExportedTypes().Where(x => typeof(DbContext).IsAssignableFrom(x)).ToList();
if (dcModule != null && dcModule.Count > 0)
{
foreach (var module in dcModule)
{
foreach (var pro in module.GetProperties())
{
if (pro.PropertyType.IsGeneric(typeof(DbSet<>)))
{
if (!allTypes.Contains(pro.PropertyType.GenericTypeArguments[0], new TypeComparer()))
{
allTypes.Add(pro.PropertyType.GenericTypeArguments[0]);
}
}
}
}
}
}
catch { }
}
_allModels = allTypes;
}
return _allModels;
}
public static SimpleMenu FindMenu(string url, List<SimpleMenu> menus)
{
if (url == null)