using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace HT.Cloud.Code
{
public class FormUtil
{
///
/// 获取值
///
/// The form.
/// System.String.
public static List SetValue(string content)
{
List list = JsonHelper.ToObject>(content);
List temp = new List();
SetFormValue(list, temp);
return temp;
}
private static List SetFormValue(List list, List temp)
{
foreach (var item in list)
{
if (item.tag == "grid")
{
foreach (var column in item.columns)
{
SetFormValue(column.list, temp);
}
}
else
{
temp.Add(item.id);
}
}
return temp;
}
public static List SetValueByWeb(string webForm)
{
var path = AppDomain.CurrentDomain.RelativeSearchPath ?? AppDomain.CurrentDomain.BaseDirectory;
var referencedAssemblies = Directory.GetFiles(path, "*.dll").Select(Assembly.LoadFrom).ToArray();
var t = referencedAssemblies
.SelectMany(a => a.GetTypes().Where(t => t.FullName.Contains("HT.Cloud.Domain.") && t.FullName.Contains("." + webForm + "Entity"))).First();
List temp = new List();
PropertyInfo[] pArray = t.GetProperties();
Array.ForEach(pArray, p =>
{
temp.Add(p.Name);
});
return temp;
}
}
}