动态移动表格+动态删除指定列
continuous-integration/drone/push Build is passing

This commit is contained in:
hang
2024-10-13 02:38:43 +08:00
parent fd3fc0ea03
commit f1be4eaf5f
5 changed files with 161 additions and 46 deletions
@@ -32,12 +32,23 @@ namespace IRaCIS.Core.Infrastructure.Extention
return JsonConvert.SerializeObject(obj, new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm:ss", ReferenceLoopHandling = ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Ignore });
}
// 通过类型参数反序列化 JSON 字符串为指定类型的对象
/// <summary>
/// 通过类型参数反序列化 JSON 字符串为指定类型的对象
/// </summary>
/// <param name="jsonStr"></param>
/// <param name="type"></param>
/// <returns></returns>
public static object JsonStrToObject(this string jsonStr, Type type)
{
return JsonConvert.DeserializeObject(jsonStr, type);
}
public static Dictionary<string, object> ToDictionary(this object obj)
{
var json = JsonConvert.SerializeObject(obj, new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm:ss", Formatting = Formatting.Indented, ReferenceLoopHandling = ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Include });
return JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
}
/// <summary>
/// 将对象序列化成稽查需要的Json字符串
/// </summary>
@@ -64,9 +75,7 @@ namespace IRaCIS.Core.Infrastructure.Extention
foreach (PropertyInfo property in properties)
{
string propertyName = property.Name;
Console.WriteLine(propertyName);
object propertyValue = property.GetValue(obj);
Console.WriteLine(propertyName);
// 如果属性的类型是枚举,将其值保留为整数
if (property.PropertyType.IsEnum || (Nullable.GetUnderlyingType(property.PropertyType)?.IsEnum == true && propertyValue!=null) )
{