Added Make and Model and Attributes to AssetDescription

This commit is contained in:
2025-10-09 09:54:40 +02:00
parent 945d848516
commit 97b97f589c
4 changed files with 42 additions and 49 deletions

View File

@@ -0,0 +1,32 @@
namespace Berufsschule_HAM.Helpers;
public static class AttributesHelper
{
public static void UpdateNonNullProperties(object source, object target)
{
if (source == null || target == null) return;
var sourceProperties = source.GetType().GetProperties();
var targetProperties = target.GetType().GetProperties();
foreach (var sourceProperty in sourceProperties)
{
if (sourceProperty.CanRead)
{
var sourceValue = sourceProperty.GetValue(source);
if (sourceValue == null) continue;
var targetProperty = targetProperties.FirstOrDefault(p =>
p.Name == sourceProperty.Name &&
p.CanWrite &&
p.PropertyType == sourceProperty.PropertyType);
if (targetProperty != null)
{
targetProperty.SetValue(target, sourceValue);
}
}
}
}
}