mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Data model - More WIP stuff woo
This commit is contained in:
1 parent
3e937f6256
commit
2f3ce2e494
2 files changed
+65
-35
No files matched your search
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Attributes;
|
||||
using Artemis.Core.Plugins.Abstract.DataModels;
|
||||
using Artemis.UI.Exceptions;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.DataModelVisualization
|
||||
{
|
||||
public class DataModelViewModel : PropertyChangedBase
|
||||
{
|
||||
public DataModelViewModel(DataModel dataModel)
|
||||
{
|
||||
if (!DataModel.Initialized)
|
||||
throw new ArtemisUIException("Cannot create view model for data model that is not yet initialized");
|
||||
|
||||
DataModel = dataModel;
|
||||
}
|
||||
|
||||
public DataModelViewModel(DataModel parent, DataModel dataModel)
|
||||
{
|
||||
if (!DataModel.Initialized)
|
||||
throw new ArtemisUIException("Cannot create view model for data model that is not yet initialized");
|
||||
|
||||
Parent = parent;
|
||||
DataModel = dataModel;
|
||||
}
|
||||
|
||||
public DataModel DataModel { get; }
|
||||
public DataModel Parent { get; set; }
|
||||
|
||||
|
||||
private void PopulateProperties()
|
||||
{
|
||||
foreach (var propertyInfo in DataModel.GetType().GetProperties())
|
||||
{
|
||||
var dataModelPropertyAttribute = (DataModelPropertyAttribute) Attribute.GetCustomAttribute(propertyInfo, typeof(DataModelPropertyAttribute));
|
||||
if (dataModelPropertyAttribute == null)
|
||||
continue;
|
||||
|
||||
// For child data models create another data model view model
|
||||
if (typeof(DataModel).IsAssignableFrom(propertyInfo.PropertyType))
|
||||
{
|
||||
}
|
||||
// For primitives, create a property view model
|
||||
else if (propertyInfo.PropertyType.IsPrimitive)
|
||||
{
|
||||
}
|
||||
// For anything else check if it has any child primitives and if so create a property container view model
|
||||
else if (propertyInfo.PropertyType.GetProperties().Any(p => p.PropertyType.IsPrimitive))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user