Merge remote-tracking branch 'origin/master'

This commit is contained in:
SpoinkyNL committed 2020-10-13 00:01:12 +02:00
commit 1b46ef4f81
9 files changed
+91 -128

No files matched your search

@@ -142,79 +142,6 @@ namespace Artemis.Core.DataModelExpansions
return value as T;
}
internal bool ContainsPath(string? path)
{
if (path == null)
return false;
string[] parts = path.Split('.');
Type? current = GetType();
foreach (string part in parts)
{
PropertyInfo? property = current?.GetProperty(part);
current = property?.PropertyType;
if (property == null)
return false;
}
return true;
}
internal Type GetTypeAtPath(string path)
{
if (!ContainsPath(path))
return null;
string[] parts = path.Split('.');
Type current = GetType();
Type result = null;
foreach (string part in parts)
{
PropertyInfo? property = current.GetProperty(part);
current = property.PropertyType;
result = property.PropertyType;
}
return result;
}
internal Type GetListTypeInPath(string path)
{
if (!ContainsPath(path))
return null;
string[] parts = path.Split('.');
Type current = GetType();
int index = 0;
foreach (string part in parts)
{
// Only return a type if the path CONTAINS a list, not if it points TO a list
if (index == parts.Length - 1)
return null;
PropertyInfo? property = current.GetProperty(part);
// For lists, look into the list type instead of the list itself
if (typeof(IList).IsAssignableFrom(property.PropertyType))
return property.PropertyType.GetGenericArguments()[0];
current = property.PropertyType;
index++;
}
return null;
}
internal Type GetListTypeAtPath(string path)
{
if (!ContainsPath(path))
return null;
Type child = GetTypeAtPath(path);
return child.GenericTypeArguments.Length > 0 ? child.GenericTypeArguments[0] : null;
}
#region Events
/// <summary>