mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Display conditions - List predicates WIP
This commit is contained in:
1 parent
cb69760971
commit
ae708fa26a
14 files changed
+162
-95
No files matched your search
@@ -37,6 +37,10 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
|
||||
public override bool Evaluate()
|
||||
{
|
||||
// If there are less than two children, ignore the boolean operator
|
||||
if (Children.Count <= 2)
|
||||
return Children.All(c => c.Evaluate());
|
||||
|
||||
switch (BooleanOperator)
|
||||
{
|
||||
case BooleanOperator.And:
|
||||
|
||||
@@ -14,6 +14,9 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
{
|
||||
Parent = parent;
|
||||
DisplayConditionListPredicateEntity = new DisplayConditionListPredicateEntity();
|
||||
|
||||
// There is always a child root group, add it
|
||||
AddChild(new DisplayConditionGroup(this));
|
||||
}
|
||||
|
||||
public DisplayConditionListPredicate(DisplayConditionPart parent, DisplayConditionListPredicateEntity entity)
|
||||
@@ -22,15 +25,15 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
DisplayConditionListPredicateEntity = entity;
|
||||
ListOperator = (ListOperator) entity.ListOperator;
|
||||
|
||||
foreach (var childEntity in DisplayConditionListPredicateEntity.Children)
|
||||
// There should only be one child and it should be a group
|
||||
var rootGroup = DisplayConditionListPredicateEntity.Children.SingleOrDefault() as DisplayConditionGroupEntity;
|
||||
if (rootGroup == null)
|
||||
{
|
||||
if (childEntity is DisplayConditionGroupEntity groupEntity)
|
||||
AddChild(new DisplayConditionGroup(this, groupEntity));
|
||||
else if (childEntity is DisplayConditionPredicateEntity predicateEntity)
|
||||
AddChild(new DisplayConditionPredicate(this, predicateEntity));
|
||||
else if (childEntity is DisplayConditionListPredicateEntity listPredicateEntity)
|
||||
AddChild(new DisplayConditionListPredicate(this, listPredicateEntity));
|
||||
DisplayConditionListPredicateEntity.Children.Clear();
|
||||
AddChild(new DisplayConditionGroup(this));
|
||||
}
|
||||
else
|
||||
AddChild(new DisplayConditionGroup(this, rootGroup));
|
||||
}
|
||||
|
||||
public DisplayConditionListPredicateEntity DisplayConditionListPredicateEntity { get; set; }
|
||||
@@ -76,8 +79,8 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
}
|
||||
|
||||
// Children
|
||||
foreach (var child in Children)
|
||||
child.Initialize(dataModelService);
|
||||
var rootGroup = (DisplayConditionGroup) Children.Single();
|
||||
rootGroup.Initialize(dataModelService);
|
||||
}
|
||||
|
||||
public void UpdateList(DataModel dataModel, string path)
|
||||
|
||||
Reference in new issue
Block a user