Display conditions - Moved pridacte update logic from VM to model

This commit is contained in:
SpoinkyNL committed 2020-07-09 23:45:34 +02:00
1 parent f39e4d719c
commit 4dfc61ab7d
4 files changed
+150 -40

No files matched your search

@@ -1,4 +1,5 @@
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
using System;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
using Artemis.Core.Plugins.Models;
namespace Artemis.Core.Plugins.Abstract.DataModels
@@ -16,5 +17,39 @@ namespace Artemis.Core.Plugins.Abstract.DataModels
/// </summary>
[DataModelIgnore]
public DataModelPropertyAttribute DataModelDescription { get; internal set; }
public bool ContainsPath(string path)
{
var parts = path.Split('.');
var current = GetType();
foreach (var part in parts)
{
var property = current?.GetProperty(part);
current = property?.PropertyType;
if (property == null)
return false;
}
return true;
}
public Type GetTypeAtPath(string path)
{
if (!ContainsPath(path))
return null;
var parts = path.Split('.');
var current = GetType();
Type result = null;
foreach (var part in parts)
{
var property = current.GetProperty(part);
current = property.PropertyType;
result = property.PropertyType;
}
return result;
}
}
}