优化了添加设备时,并添加和更新菜单栏

This commit is contained in:
2025-06-26 22:40:20 +08:00
parent 244b67391d
commit a04bfc2010
8 changed files with 63 additions and 155 deletions

View File

@@ -1,36 +0,0 @@
using System.Reflection;
namespace PMSWPF.Helper;
public class CovertHelper
{
public static List<TTarget> ConvertList<TSource, TTarget>(List<TSource> sourceList)
{
var targetList = new List<TTarget>();
var sourceType = typeof(TSource);
var targetType = typeof(TTarget);
// 获取源类型和目标类型的公共属性
var sourceProperties = sourceType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
var targetProperties = targetType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (var sourceObject in sourceList)
{
var targetObject = Activator.CreateInstance<TTarget>();
foreach (var targetProperty in targetProperties)
{
var sourceProperty = sourceProperties.FirstOrDefault(p =>
p.Name == targetProperty.Name && p.PropertyType == targetProperty.PropertyType);
if (sourceProperty != null)
{
var value = sourceProperty.GetValue(sourceObject);
targetProperty.SetValue(targetObject, value);
}
}
targetList.Add(targetObject);
}
return targetList;
}
}

View File

@@ -1,17 +0,0 @@
using PMSWPF.Data;
namespace PMSWPF.Helper;
public class SqlSugarHelper
{
private DbContext _db;
public SqlSugarHelper()
{
_db = new DbContext();
}
public void InitTables()
{
}
}