мини-доработка
This commit is contained in:
parent
da7f9c64e9
commit
72db78b9c8
@ -13,21 +13,9 @@ namespace AutomomilePlantFileImplement.Implements
|
|||||||
public List<T>? GetList<T>() where T : class, new()
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
{
|
{
|
||||||
var context = DataFileSingleton.GetInstance();
|
var context = DataFileSingleton.GetInstance();
|
||||||
Type myType = typeof(DataFileSingleton);
|
return (List<T>?)context.GetType().GetProperties().FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetProperty("Item").PropertyType == typeof(T)).GetValue(context);
|
||||||
string property = $"{typeof(T).FullName}";
|
|
||||||
string nameList = "";
|
|
||||||
foreach (PropertyInfo prop in myType.GetProperties(
|
|
||||||
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static))
|
|
||||||
{
|
|
||||||
var list = prop.GetValue(context);
|
|
||||||
var typeList = list.GetType().GetGenericArguments().Single();
|
|
||||||
if (property.Equals($"{typeList.FullName}"))
|
|
||||||
{ nameList = prop.Name; break; }
|
|
||||||
}
|
|
||||||
var propertyInfo = myType.GetProperty(nameList);
|
|
||||||
var values = (List<T>)propertyInfo.GetValue(context);
|
|
||||||
return values;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user