мини-доработка

This commit is contained in:
Володя 2023-05-16 13:18:41 +03:00
parent da7f9c64e9
commit 72db78b9c8

View File

@ -13,21 +13,9 @@ namespace AutomomilePlantFileImplement.Implements
public List<T>? GetList<T>() where T : class, new()
{
var context = DataFileSingleton.GetInstance();
Type myType = typeof(DataFileSingleton);
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;
return (List<T>?)context.GetType().GetProperties().FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetProperty("Item").PropertyType == typeof(T)).GetValue(context);
}
public Type? GetTypeByModelInterface(string modelInterfaceName)