чет подправила, у меня там очень много закомментированного кода было...

This commit is contained in:
Елена Бакальская 2024-11-05 18:50:01 +04:00
parent dd9e86a211
commit da0b0b3c97
2 changed files with 2 additions and 65 deletions

View File

@ -68,55 +68,6 @@ namespace UserComponentsOption19
}
}
/// <summary>
/// Метод получения объекта из строки с заполнением свойств ентого объекта через рефлексию
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
//public T? GetObjectFromSelectedRow<T>() where T : class, new()
//{
// if (listBox.SelectedIndex == -1 || listBox.SelectedItem == null)
// return null;
// string? selectedString = listBox.SelectedItem.ToString();
// T obj = new T();
// Type objectType = typeof(T);
// char[] punctMarks = { ',', '.', ';', ':' };
// string selString = selectedString;
// string tempString = _templateString;
// string[] selList = selString.Split();
// string[] tempList = tempString.Split();
// foreach (var property in objectType.GetProperties())
// {
// string placeholder = $"{_startPropertyChar}{property.Name}{_endPropertyChar}";
// for (int i = 0; i < tempList.Length; i++)
// {
// if (placeholder == tempList[i].Trim(punctMarks))
// {
// Type propertyType = property.PropertyType;
// Type? underlyingType = Nullable.GetUnderlyingType(propertyType);
// if (underlyingType != null)
// {
// object? converted = string.IsNullOrWhiteSpace(selList[i]) ? null : Convert.ChangeType(selList[i].Trim(punctMarks), underlyingType);
// property.SetValue(obj, converted);
// }
// else
// {
// property.SetValue(obj, Convert.ChangeType(selList[i].Trim(punctMarks), property.PropertyType));
// }
// }
// }
// }
// return obj;
//}
public T? GetObjectFromSelectedRow<T>() where T : class, new()
{
if (listBox.SelectedIndex == -1 || listBox.SelectedItem == null)
@ -128,22 +79,7 @@ namespace UserComponentsOption19
Type objectType = typeof(T);
string selString = selectedString;
string tempString =
_templateString;
string tempString = _templateString;
List<string> arraySubstrings = new List<string>();
List<string> arrayPropertyNames = new List<string>();

View File

@ -5,6 +5,7 @@
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>