questHelper done

This commit is contained in:
CWX
2025-01-22 11:15:14 +00:00
parent edb68d7f8b
commit e1ec67619d
2 changed files with 339 additions and 15 deletions
+29
View File
@@ -48,5 +48,34 @@ namespace SptCommon.Extensions
return default;
return (T?)cachedProperty.GetValue(obj);
}
public static List<T?> GetAllPropValuesAsList<T>(this object? obj)
{
ArgumentNullException.ThrowIfNull(obj);
var list = obj.GetType().GetProperties();
var result = new List<T?>();
foreach (var prop in list)
{
result.Add((T?)prop.GetValue(obj));
}
return result;
}
public static Dictionary<string, T?> GetAllPropsAsDict<T>(this object? obj)
{
var result = new Dictionary<string, T?>();
var props = obj.GetType().GetProperties();
foreach (var prop in props)
{
result.Add(prop.Name, (T?)prop.GetValue(obj));
}
return result;
}
}
}