Morozov V.S. LabWork8 #11

Closed
VoldemarProger wants to merge 2 commits from LabWork8 into LabWork7
Showing only changes of commit 72db78b9c8 - Show all commits

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)