|
@@ -393,13 +393,19 @@ namespace InABox.Core
|
|
|
: default;
|
|
|
}
|
|
|
|
|
|
- public static Dictionary<string, object> GetValues<T>(this T sender, bool all) where T : BaseObject
|
|
|
+ public static Dictionary<string, object> GetValues<T>(this T sender, bool all, bool followlinks = false) where T : BaseObject
|
|
|
{
|
|
|
var result = new Dictionary<string, object>();
|
|
|
- LoadValues(sender, result, "", all, false);
|
|
|
+ LoadValues(sender, result, "", all, false, followlinks);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ public static void SetValues<T>(this T sender, Dictionary<string, object> values)
|
|
|
+ {
|
|
|
+ foreach (var value in values)
|
|
|
+ CoreUtils.SetPropertyValue(sender, value.Key, value.Value);
|
|
|
+ }
|
|
|
+
|
|
|
public static Dictionary<string, object> GetOriginaValues<T>(this T sender, bool all) where T : BaseObject
|
|
|
{
|
|
|
var result = new Dictionary<string, object>();
|
|
@@ -407,7 +413,7 @@ namespace InABox.Core
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private static void LoadValues(BaseObject sender, Dictionary<string, object?> values, string prefix, bool all, bool original)
|
|
|
+ private static void LoadValues(BaseObject sender, Dictionary<string, object?> values, string prefix, bool all, bool original, bool followlinks = false)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -424,7 +430,7 @@ namespace InABox.Core
|
|
|
{
|
|
|
var child = prop.GetValue(sender) as BaseObject;
|
|
|
if (child != null)
|
|
|
- LoadValues(child, values, string.IsNullOrWhiteSpace(prefix) ? prop.Name : prefix + "." + prop.Name, all, original);
|
|
|
+ LoadValues(child, values, string.IsNullOrWhiteSpace(prefix) ? prop.Name : prefix + "." + prop.Name, all, original, followlinks);
|
|
|
}
|
|
|
else if (prop.PropertyType.GetInterfaces().Contains(typeof(IEntityLink)))
|
|
|
{
|
|
@@ -446,6 +452,8 @@ namespace InABox.Core
|
|
|
? child.OriginalValues.ContainsKey("ID") ? child.OriginalValues["ID"] : Guid.Empty
|
|
|
: CoreUtils.GetPropertyValue(child, "ID");
|
|
|
}
|
|
|
+ if (followlinks)
|
|
|
+ LoadValues(child, values, string.IsNullOrWhiteSpace(prefix) ? prop.Name : prefix + "." + prop.Name, all, original, followlinks);
|
|
|
}
|
|
|
}
|
|
|
else if (prop.PropertyType.GetInterfaces().Contains(typeof(IBaseObject)))
|