mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Data model - Improved encapsulation
Conditions - Renamed from DisplayConditions to DataModelConditions to better match their nature Core - More documentation
This commit is contained in:
1 parent
6b93b1c878
commit
a646ff95ed
39 files changed
+581
-355
No files matched your search
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Artemis.Core.DataModelExpansions
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an attribute that marks a data model property to be ignored by the UI
|
||||
/// </summary>
|
||||
public class DataModelIgnoreAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Artemis.Core.DataModelExpansions
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an attribute that describes a data model property
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class DataModelPropertyAttribute : Attribute
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Artemis.Core.DataModelExpansions
|
||||
[DataModelIgnore]
|
||||
public bool IsExpansion { get; internal set; }
|
||||
|
||||
public bool ContainsPath(string path)
|
||||
internal bool ContainsPath(string path)
|
||||
{
|
||||
var parts = path.Split('.');
|
||||
var current = GetType();
|
||||
@@ -43,7 +43,7 @@ namespace Artemis.Core.DataModelExpansions
|
||||
return true;
|
||||
}
|
||||
|
||||
public Type GetTypeAtPath(string path)
|
||||
internal Type GetTypeAtPath(string path)
|
||||
{
|
||||
if (!ContainsPath(path))
|
||||
return null;
|
||||
@@ -62,7 +62,7 @@ namespace Artemis.Core.DataModelExpansions
|
||||
return result;
|
||||
}
|
||||
|
||||
public Type GetListTypeInPath(string path)
|
||||
internal Type GetListTypeInPath(string path)
|
||||
{
|
||||
if (!ContainsPath(path))
|
||||
return null;
|
||||
@@ -90,7 +90,7 @@ namespace Artemis.Core.DataModelExpansions
|
||||
return null;
|
||||
}
|
||||
|
||||
public Type GetListTypeAtPath(string path)
|
||||
internal Type GetListTypeAtPath(string path)
|
||||
{
|
||||
if (!ContainsPath(path))
|
||||
return null;
|
||||
@@ -98,29 +98,7 @@ namespace Artemis.Core.DataModelExpansions
|
||||
var child = GetTypeAtPath(path);
|
||||
return child.GenericTypeArguments.Length > 0 ? child.GenericTypeArguments[0] : null;
|
||||
}
|
||||
|
||||
public string GetListInnerPath(string path)
|
||||
{
|
||||
if (GetListTypeInPath(path) == null)
|
||||
throw new ArtemisCoreException($"Cannot determine inner list path at {path} because it does not contain a list");
|
||||
|
||||
var parts = path.Split('.');
|
||||
var current = GetType();
|
||||
|
||||
for (var index = 0; index < parts.Length; index++)
|
||||
{
|
||||
var part = parts[index];
|
||||
var property = current.GetProperty(part);
|
||||
|
||||
if (typeof(IList).IsAssignableFrom(property.PropertyType))
|
||||
return string.Join('.', parts.Skip(index + 1).ToList());
|
||||
|
||||
current = property.PropertyType;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a read-only list of all properties in this datamodel that are to be ignored
|
||||
/// </summary>
|
||||
|
||||
@@ -10,14 +10,22 @@ namespace Artemis.Core.DataModelExpansions
|
||||
/// </summary>
|
||||
public abstract class BaseDataModelExpansion : Plugin
|
||||
{
|
||||
protected readonly List<PropertyInfo> HiddenPropertiesList = new List<PropertyInfo>();
|
||||
/// <summary>
|
||||
/// Gets a list of all properties ignored at runtime using <c>IgnoreProperty(x => x.y)</c>
|
||||
/// </summary>
|
||||
protected internal readonly List<PropertyInfo> HiddenPropertiesList = new List<PropertyInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all properties ignored at runtime using IgnoreProperty(x => x.y)
|
||||
/// Gets a list of all properties ignored at runtime using <c>IgnoreProperty(x => x.y)</c>
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<PropertyInfo> HiddenProperties => HiddenPropertiesList.AsReadOnly();
|
||||
|
||||
internal DataModel InternalDataModel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called each frame when the data model should update
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Time in seconds since the last update</param>
|
||||
public abstract void Update(double deltaTime);
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user