Fix region bug

This commit is contained in:
Dan Clark
2025-02-12 20:59:38 +00:00
parent 92ea28d647
commit 5740e03ba1
24 changed files with 277 additions and 183 deletions
+16 -10
View File
@@ -4,17 +4,10 @@ namespace Toolkit.Foundation;
public static class ObjectExtensions
{
public static object? GetPropertyValue(this object obj, Func<object> selector)
public static T Also<T>(this T value, Action<T> action)
{
Type type = obj.GetType();
object? key = selector();
if (type.GetProperty($"{key}") is PropertyInfo property && property.GetValue(obj) is { } value)
{
return value;
}
return null;
action(value);
return value;
}
public static TAttribute? GetAttribute<TAttribute>(this object obj)
@@ -40,4 +33,17 @@ public static class ObjectExtensions
return Enumerable.Empty<TAttribute>();
}
public static object? GetPropertyValue(this object obj, Func<object> selector)
{
Type type = obj.GetType();
object? key = selector();
if (type.GetProperty($"{key}") is PropertyInfo property && property.GetValue(obj) is { } value)
{
return value;
}
return null;
}
}