From da132fa4e986af22db736f95c4787513e40f9284 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Tue, 6 Oct 2020 23:39:42 +0200 Subject: [PATCH] Conditions - Move to new paths API (WIP) --- .../Profile/Conditions/ConditionOperator.cs | 2 +- .../Conditions/DataModelConditionList.cs | 131 +++------ .../Conditions/DataModelConditionPredicate.cs | 268 ++++++------------ .../Models/Profile/DataModel/DataModelPath.cs | 2 +- .../DataModelConditionListEntity.cs | 4 +- .../DataModelConditionPredicateEntity.cs | 8 +- src/Artemis.sln.DotSettings | 17 +- 7 files changed, 136 insertions(+), 296 deletions(-) diff --git a/src/Artemis.Core/Models/Profile/Conditions/ConditionOperator.cs b/src/Artemis.Core/Models/Profile/Conditions/ConditionOperator.cs index 662902ee2..9fe9461bd 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/ConditionOperator.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/ConditionOperator.cs @@ -50,6 +50,6 @@ namespace Artemis.Core /// /// The parameter on the left side of the expression /// The parameter on the right side of the expression - public abstract bool Evaluate(object a, object b); + public abstract bool Evaluate(object? a, object? b); } } \ No newline at end of file diff --git a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionList.cs b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionList.cs index 48f87e8cd..58fac9e3d 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionList.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionList.cs @@ -2,7 +2,6 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; using Artemis.Core.DataModelExpansions; using Artemis.Storage.Entities.Profile.Abstract; using Artemis.Storage.Entities.Profile.Conditions; @@ -37,37 +36,27 @@ namespace Artemis.Core Initialize(); } - internal DataModelConditionListEntity Entity { get; set; } - /// /// Gets or sets the list operator /// public ListOperator ListOperator { get; set; } + /// + /// Gets the path of the list property + /// + public DataModelPath? ListPath { get; set; } + /// /// Gets the type of the content of the list this predicate is evaluated on /// - public Type ListType { get; set; } + public Type? ListType { get; set; } /// /// Gets whether the list contains primitives /// public bool IsPrimitiveList { get; set; } - /// - /// Gets the currently used instance of the list data model - /// - public DataModel ListDataModel { get; private set; } - - /// - /// Gets the path of the list property in the - /// - public string ListPropertyPath { get; private set; } - - /// - /// Gets the compiled function that accesses the list this condition evaluates on - /// - public Func CompiledListAccessor { get; private set; } + internal DataModelConditionListEntity Entity { get; set; } /// public override bool Evaluate() @@ -75,10 +64,10 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("DataModelConditionList"); - if (CompiledListAccessor == null) + if (ListPath == null || !ListPath.IsValid) return false; - return EvaluateObject(CompiledListAccessor(ListDataModel)); + return EvaluateObject(ListPath.GetValue()); } /// @@ -86,7 +75,7 @@ namespace Artemis.Core /// /// The data model of the list /// The path pointing to the list inside the list - public void UpdateList(DataModel dataModel, string path) + public void UpdateList(DataModel? dataModel, string? path) { if (_disposed) throw new ObjectDisposedException("DataModelConditionList"); @@ -96,17 +85,23 @@ namespace Artemis.Core if (dataModel == null && path != null) throw new ArtemisCoreException("If path is provided, a data model is also required"); - if (dataModel != null) + ListPath?.Dispose(); + if (dataModel != null && path != null) { - Type listType = dataModel.GetListTypeAtPath(path); - if (listType == null) - throw new ArtemisCoreException($"Data model of type {dataModel.GetType().Name} does not contain a list at path '{path}'"); + DataModelPath newPath = new DataModelPath(dataModel, path); + if (!newPath.IsValid) + throw new ArtemisCoreException($"New left path '{newPath}' is invalid"); + Type listType = newPath.GetPropertyType()!; + if (!typeof(IList).IsAssignableFrom(listType)) + throw new ArtemisCoreException($"Data model of type {dataModel.GetType().Name} does not contain a list at path '{newPath}'"); ListType = listType; IsPrimitiveList = listType.IsPrimitive || listType.IsEnum || listType == typeof(string); - - ListDataModel = dataModel; - ListPropertyPath = path; + } + else + { + ListPath = null; + ListType = null; } // Remove the old root group that was tied to the old data model @@ -118,7 +113,6 @@ namespace Artemis.Core // Create a new root group AddChild(new DataModelConditionGroup(this)); - CreateExpression(); } #region IDisposable @@ -128,8 +122,7 @@ namespace Artemis.Core { _disposed = true; - DataModelStore.DataModelAdded -= DataModelStoreOnDataModelAdded; - DataModelStore.DataModelRemoved -= DataModelStoreOnDataModelRemoved; + ListPath?.Dispose(); foreach (DataModelConditionPart child in Children) child.Dispose(); @@ -139,7 +132,7 @@ namespace Artemis.Core #endregion - internal override bool EvaluateObject(object target) + internal override bool EvaluateObject(object? target) { if (_disposed) throw new ObjectDisposedException("DataModelConditionList"); @@ -163,11 +156,8 @@ namespace Artemis.Core internal override void Save() { // Target list - if (ListDataModel != null) - { - Entity.ListDataModelGuid = ListDataModel.PluginInfo.Guid; - Entity.ListPropertyPath = ListPropertyPath; - } + ListPath?.Save(); + Entity.ListPath = ListPath?.Entity; // Operator Entity.ListOperator = (int) ListOperator; @@ -186,80 +176,27 @@ namespace Artemis.Core internal void Initialize() { - DataModelStore.DataModelAdded += DataModelStoreOnDataModelAdded; - DataModelStore.DataModelRemoved += DataModelStoreOnDataModelRemoved; - if (Entity.ListDataModelGuid == null) + if (Entity.ListPath == null) return; - // Get the data model ... - DataModel dataModel = DataModelStore.Get(Entity.ListDataModelGuid.Value)?.DataModel; - if (dataModel == null) - return; - // ... and ensure the path is valid - Type listType = dataModel.GetListTypeAtPath(Entity.ListPropertyPath); - if (listType == null) + // Ensure the list path is valid and points to a list + DataModelPath listPath = new DataModelPath(null, Entity.ListPath); + if (!listPath.IsValid || !typeof(IList).IsAssignableFrom(listPath.GetPropertyType())) return; - ListType = listType; - IsPrimitiveList = listType.IsPrimitive || listType.IsEnum || listType == typeof(string); - ListDataModel = dataModel; - ListPropertyPath = Entity.ListPropertyPath; - - CreateExpression(); - - if (ListDataModel == null) - return; + ListPath = listPath; // There should only be one child and it should be a group if (Entity.Children.SingleOrDefault() is DataModelConditionGroupEntity rootGroup) + { AddChild(new DataModelConditionGroup(this, rootGroup)); + } else { Entity.Children.Clear(); AddChild(new DataModelConditionGroup(this)); } } - - private void CreateExpression() - { - if (_disposed) - throw new ObjectDisposedException("DataModelConditionList"); - - ParameterExpression parameter = Expression.Parameter(typeof(object), "listDataModel"); - Expression accessor = ListPropertyPath.Split('.').Aggregate( - Expression.Convert(parameter, ListDataModel.GetType()), - Expression.Property - ); - accessor = Expression.Convert(accessor, typeof(IList)); - - Expression> lambda = Expression.Lambda>(accessor, parameter); - CompiledListAccessor = lambda.Compile(); - } - - - #region Event handlers - - private void DataModelStoreOnDataModelAdded(object sender, DataModelStoreEvent e) - { - DataModel dataModel = e.Registration.DataModel; - if (dataModel.PluginInfo.Guid == Entity.ListDataModelGuid && dataModel.ContainsPath(Entity.ListPropertyPath)) - { - ListDataModel = dataModel; - ListPropertyPath = Entity.ListPropertyPath; - CreateExpression(); - } - } - - private void DataModelStoreOnDataModelRemoved(object sender, DataModelStoreEvent e) - { - if (ListDataModel != e.Registration.DataModel) - return; - - ListDataModel = null; - CompiledListAccessor = null; - } - - #endregion } /// diff --git a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionPredicate.cs b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionPredicate.cs index 342eed1d0..d5869fdf5 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionPredicate.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionPredicate.cs @@ -1,6 +1,4 @@ using System; -using System.Linq; -using System.Linq.Expressions; using Artemis.Core.DataModelExpansions; using Artemis.Storage.Entities.Profile.Abstract; using Artemis.Storage.Entities.Profile.Conditions; @@ -45,36 +43,23 @@ namespace Artemis.Core /// /// Gets the operator /// - public ConditionOperator Operator { get; private set; } + public ConditionOperator? Operator { get; private set; } /// - /// Gets the currently used instance of the left data model + /// Gets the path of the left property /// - public DataModel LeftDataModel { get; private set; } + public DataModelPath? LeftPath { get; set; } /// - /// Gets the path of the left property in the + /// Gets the path of the right property /// - public string LeftPropertyPath { get; private set; } - - /// - /// Gets the currently used instance of the right data model - /// - public DataModel RightDataModel { get; private set; } - - /// - /// Gets the path of the right property in the - /// - public string RightPropertyPath { get; private set; } + public DataModelPath? RightPath { get; set; } /// /// Gets the right static value, only used it is /// /// - public object RightStaticValue { get; private set; } - - public Func LeftSideAccessor { get; set; } - public Func RightSideAccessor { get; set; } + public object? RightStaticValue { get; private set; } internal DataModelConditionPredicateEntity Entity { get; set; } @@ -83,26 +68,28 @@ namespace Artemis.Core /// /// The data model of the left side value /// The path pointing to the left side value inside the data model - public void UpdateLeftSide(DataModel dataModel, string path) + public void UpdateLeftSide(DataModel? dataModel, string? path) { if (dataModel != null && path == null) throw new ArtemisCoreException("If a data model is provided, a path is also required"); if (dataModel == null && path != null) throw new ArtemisCoreException("If path is provided, a data model is also required"); - if (dataModel != null) + LeftPath?.Dispose(); + if (dataModel != null && path != null) { - if (!dataModel.ContainsPath(path)) - throw new ArtemisCoreException($"Data model of type {dataModel.GetType().Name} does not contain a property at path '{path}'"); + DataModelPath newPath = new DataModelPath(dataModel, path); + if (!newPath.IsValid) + throw new ArtemisCoreException($"New left path '{newPath}' is invalid"); + LeftPath = newPath; + } + else + { + LeftPath = null; } - - LeftDataModel = dataModel; - LeftPropertyPath = path; ValidateOperator(); ValidateRightSide(); - - CreateAccessors(); } /// @@ -110,44 +97,48 @@ namespace Artemis.Core /// /// The data model of the right side value /// The path pointing to the right side value inside the data model - public void UpdateRightSide(DataModel dataModel, string path) + public void UpdateRightSide(DataModel? dataModel, string? path) { if (dataModel != null && path == null) throw new ArtemisCoreException("If a data model is provided, a path is also required"); if (dataModel == null && path != null) throw new ArtemisCoreException("If path is provided, a data model is also required"); - if (dataModel != null) + RightPath?.Dispose(); + if (dataModel != null && path != null) { - if (!dataModel.ContainsPath(path)) - throw new ArtemisCoreException($"Data model of type {dataModel.GetType().Name} does not contain a property at path '{path}'"); + DataModelPath newPath = new DataModelPath(dataModel, path); + if (!newPath.IsValid) + throw new ArtemisCoreException($"New right path '{newPath}' is invalid"); + RightPath = newPath; + } + else + { + RightPath = null; } PredicateType = ProfileRightSideType.Dynamic; - RightDataModel = dataModel; - RightPropertyPath = path; - - CreateAccessors(); } /// /// Updates the right side of the predicate, makes the predicate static and re-compiles the expression /// /// The right side value to use - public void UpdateRightSide(object staticValue) + public void UpdateRightSide(object? staticValue) { PredicateType = ProfileRightSideType.Static; - RightDataModel = null; - RightPropertyPath = null; + RightPath?.Dispose(); + RightPath = null; // If the left side is empty simply apply the value, any validation will wait - if (LeftDataModel == null) + if (LeftPath == null || !LeftPath.IsValid) { RightStaticValue = staticValue; return; } - Type leftSideType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); + // If the left path is valid we can expect a type + Type leftSideType = LeftPath.GetPropertyType()!; // If not null ensure the types match and if not, convert it if (staticValue != null && staticValue.GetType() == leftSideType) @@ -159,63 +150,77 @@ namespace Artemis.Core RightStaticValue = Activator.CreateInstance(leftSideType); else RightStaticValue = null; - - CreateAccessors(); } /// /// Updates the operator of the predicate and re-compiles the expression /// /// - public void UpdateOperator(ConditionOperator conditionOperator) + public void UpdateOperator(ConditionOperator? conditionOperator) { // Calling CreateExpression will clear compiled expressions if (conditionOperator == null) { Operator = null; - CreateAccessors(); return; } // No need to clear compiled expressions, without a left data model they are already null - if (LeftDataModel == null) + if (LeftPath == null || !LeftPath.IsValid) { Operator = conditionOperator; return; } - Type leftType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); + Type leftType = LeftPath.GetPropertyType()!; if (!conditionOperator.SupportsType(leftType)) - { throw new ArtemisCoreException($"Cannot apply operator {conditionOperator.GetType().Name} to this predicate because " + $"it does not support left side type {leftType.Name}"); - } Operator = conditionOperator; - CreateAccessors(); } /// public override bool Evaluate() { - if (Operator == null || LeftSideAccessor == null || PredicateType != ProfileRightSideType.Static && RightSideAccessor == null) + if (Operator == null || LeftPath == null || !LeftPath.IsValid) return false; // Compare with a static value if (PredicateType == ProfileRightSideType.Static) { - object leftSideValue = LeftSideAccessor(LeftDataModel); - if (leftSideValue.GetType().IsValueType && RightStaticValue == null) + object? leftSideValue = LeftPath.GetValue(); + if (leftSideValue != null && leftSideValue.GetType().IsValueType && RightStaticValue == null) return false; return Operator.Evaluate(leftSideValue, RightStaticValue); } - // Compare with dynamic values - if (PredicateType == ProfileRightSideType.Dynamic) - return Operator.Evaluate(LeftSideAccessor(LeftDataModel), RightSideAccessor(RightDataModel)); + if (RightPath == null || !RightPath.IsValid) + return false; - return false; + // Compare with dynamic values + return Operator.Evaluate(LeftPath.GetValue(), RightPath.GetValue()); + } + + /// + public override string ToString() + { + if (PredicateType == ProfileRightSideType.Dynamic) + return $"[Dynamic] {LeftPath} {Operator.Description} {RightPath}"; + return $"[Static] {LeftPath} {Operator.Description} {RightStaticValue}"; + } + + /// + protected override void Dispose(bool disposing) + { + ConditionOperatorStore.ConditionOperatorAdded -= ConditionOperatorStoreOnConditionOperatorAdded; + ConditionOperatorStore.ConditionOperatorRemoved -= ConditionOperatorStoreOnConditionOperatorRemoved; + + LeftPath?.Dispose(); + RightPath?.Dispose(); + + base.Dispose(disposing); } /// @@ -224,22 +229,15 @@ namespace Artemis.Core return false; } - /// - public override string ToString() - { - if (PredicateType == ProfileRightSideType.Dynamic) - return $"[Dynamic] {LeftPropertyPath} {Operator.Description} {RightPropertyPath}"; - return $"[Static] {LeftPropertyPath} {Operator.Description} {RightStaticValue}"; - } - internal override void Save() { Entity.PredicateType = (int) PredicateType; - Entity.LeftDataModelGuid = LeftDataModel?.PluginInfo?.Guid; - Entity.LeftPropertyPath = LeftPropertyPath; - Entity.RightDataModelGuid = RightDataModel?.PluginInfo?.Guid; - Entity.RightPropertyPath = RightPropertyPath; + LeftPath?.Save(); + Entity.LeftPath = LeftPath?.Entity; + RightPath?.Save(); + Entity.RightPath = RightPath?.Entity; + Entity.RightStaticValue = JsonConvert.SerializeObject(RightStaticValue); Entity.OperatorPluginGuid = Operator?.PluginInfo?.Guid; @@ -248,44 +246,32 @@ namespace Artemis.Core internal void Initialize() { - DataModelStore.DataModelAdded += DataModelStoreOnDataModelAdded; - DataModelStore.DataModelRemoved += DataModelStoreOnDataModelRemoved; ConditionOperatorStore.ConditionOperatorAdded += ConditionOperatorStoreOnConditionOperatorAdded; ConditionOperatorStore.ConditionOperatorRemoved += ConditionOperatorStoreOnConditionOperatorRemoved; // Left side - if (Entity.LeftDataModelGuid != null) - { - DataModel dataModel = DataModelStore.Get(Entity.LeftDataModelGuid.Value)?.DataModel; - if (dataModel != null && dataModel.ContainsPath(Entity.LeftPropertyPath)) - UpdateLeftSide(dataModel, Entity.LeftPropertyPath); - } + if (Entity.LeftPath != null) LeftPath = new DataModelPath(null, Entity.LeftPath); // Operator if (Entity.OperatorPluginGuid != null) { - ConditionOperator conditionOperator = ConditionOperatorStore.Get(Entity.OperatorPluginGuid.Value, Entity.OperatorType)?.ConditionOperator; + ConditionOperator? conditionOperator = ConditionOperatorStore.Get(Entity.OperatorPluginGuid.Value, Entity.OperatorType)?.ConditionOperator; if (conditionOperator != null) UpdateOperator(conditionOperator); } // Right side dynamic - if (PredicateType == ProfileRightSideType.Dynamic && Entity.RightDataModelGuid != null) - { - DataModel dataModel = DataModelStore.Get(Entity.RightDataModelGuid.Value)?.DataModel; - if (dataModel != null && dataModel.ContainsPath(Entity.RightPropertyPath)) - UpdateRightSide(dataModel, Entity.RightPropertyPath); - } + if (PredicateType == ProfileRightSideType.Dynamic && Entity.RightPath != null) + RightPath = new DataModelPath(null, Entity.RightPath); // Right side static else if (PredicateType == ProfileRightSideType.Static && Entity.RightStaticValue != null) - { try { - if (LeftDataModel != null) + if (LeftPath != null && LeftPath.IsValid) { // Use the left side type so JSON.NET has a better idea what to do - Type leftSideType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); - object rightSideValue; + Type leftSideType = LeftPath.GetPropertyType()!; + object? rightSideValue; try { @@ -311,7 +297,6 @@ namespace Artemis.Core // ignored // TODO: Some logging would be nice } - } } internal override DataModelConditionPartEntity GetEntity() @@ -319,119 +304,47 @@ namespace Artemis.Core return Entity; } - private void CreateAccessors() - { - if (Operator == null) - return; - - // If the operator does not support a right side, create a static expression because the right side will simply be null - if (PredicateType == ProfileRightSideType.Dynamic && Operator.SupportsRightSide) - CreateDynamicAccessors(); - else - CreateStaticExpression(); - } - private void ValidateOperator() { - if (LeftDataModel == null || Operator == null) + if (LeftPath == null || !LeftPath.IsValid || Operator == null) return; - Type leftType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); + Type leftType = LeftPath.GetPropertyType()!; if (!Operator.SupportsType(leftType)) Operator = null; } private void ValidateRightSide() { - Type leftSideType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); + Type? leftType = LeftPath?.GetPropertyType(); if (PredicateType == ProfileRightSideType.Dynamic) { - if (RightDataModel == null) + if (RightPath == null || !RightPath.IsValid) return; - Type rightSideType = RightDataModel.GetTypeAtPath(RightPropertyPath); - if (!leftSideType.IsCastableFrom(rightSideType)) + Type rightSideType = RightPath.GetPropertyType()!; + if (leftType != null && !leftType.IsCastableFrom(rightSideType)) UpdateRightSide(null, null); } else { - if (RightStaticValue != null && leftSideType.IsCastableFrom(RightStaticValue.GetType())) + if (RightStaticValue != null && (leftType == null || leftType.IsCastableFrom(RightStaticValue.GetType()))) UpdateRightSide(RightStaticValue); else UpdateRightSide(null); } } - private void CreateDynamicAccessors() - { - if (LeftDataModel == null || RightDataModel == null || Operator == null) - return; - - Expression leftSideAccessor = ExpressionUtilities.CreateDataModelAccessor(LeftDataModel, LeftPropertyPath, "left", out ParameterExpression leftSideParameter); - Expression rightSideAccessor = ExpressionUtilities.CreateDataModelAccessor(RightDataModel, RightPropertyPath, "right", out ParameterExpression rightSideParameter); - - // A conversion may be required if the types differ - // This can cause issues if the DataModelConditionOperator wasn't accurate in it's supported types but that is not a concern here - if (rightSideAccessor.Type != leftSideAccessor.Type) - rightSideAccessor = Expression.Convert(rightSideAccessor, leftSideAccessor.Type); - - LeftSideAccessor = Expression.Lambda>(leftSideAccessor, leftSideParameter).Compile(); - RightSideAccessor = Expression.Lambda>(rightSideAccessor, rightSideParameter).Compile(); - } - - private void CreateStaticExpression() - { - if (LeftDataModel == null || Operator == null) - return; - - UnaryExpression leftSideAccessor = Expression.Convert( - ExpressionUtilities.CreateDataModelAccessor(LeftDataModel, LeftPropertyPath, "left", out ParameterExpression leftSideParameter), - typeof(object) - ); - - // If the left side is a value type but the input is empty, this isn't a valid expression - if (leftSideAccessor.Type.IsValueType && RightStaticValue == null) - return; - - LeftSideAccessor = Expression.Lambda>(leftSideAccessor, leftSideParameter).Compile(); - RightSideAccessor = null; - } - - #region Event handlers - private void DataModelStoreOnDataModelAdded(object sender, DataModelStoreEvent e) - { - DataModel dataModel = e.Registration.DataModel; - if (dataModel.PluginInfo.Guid == Entity.LeftDataModelGuid && dataModel.ContainsPath(Entity.LeftPropertyPath)) - UpdateLeftSide(dataModel, Entity.LeftPropertyPath); - if (dataModel.PluginInfo.Guid == Entity.RightDataModelGuid && dataModel.ContainsPath(Entity.RightPropertyPath)) - UpdateRightSide(dataModel, Entity.RightPropertyPath); - } - - private void DataModelStoreOnDataModelRemoved(object sender, DataModelStoreEvent e) - { - if (LeftDataModel == e.Registration.DataModel) - { - LeftSideAccessor = null; - LeftDataModel = null; - } - - if (RightDataModel == e.Registration.DataModel) - { - RightSideAccessor = null; - RightDataModel = null; - } - } - - private void ConditionOperatorStoreOnConditionOperatorAdded(object sender, ConditionOperatorStoreEvent e) + private void ConditionOperatorStoreOnConditionOperatorAdded(object? sender, ConditionOperatorStoreEvent e) { ConditionOperator conditionOperator = e.Registration.ConditionOperator; if (Entity.OperatorPluginGuid == conditionOperator.PluginInfo.Guid && Entity.OperatorType == conditionOperator.GetType().Name) UpdateOperator(conditionOperator); } - private void ConditionOperatorStoreOnConditionOperatorRemoved(object sender, ConditionOperatorStoreEvent e) + private void ConditionOperatorStoreOnConditionOperatorRemoved(object? sender, ConditionOperatorStoreEvent e) { if (e.Registration.ConditionOperator != Operator) return; @@ -440,16 +353,5 @@ namespace Artemis.Core } #endregion - - /// - protected override void Dispose(bool disposing) - { - DataModelStore.DataModelAdded -= DataModelStoreOnDataModelAdded; - DataModelStore.DataModelRemoved -= DataModelStoreOnDataModelRemoved; - ConditionOperatorStore.ConditionOperatorAdded -= ConditionOperatorStoreOnConditionOperatorAdded; - ConditionOperatorStore.ConditionOperatorRemoved -= ConditionOperatorStoreOnConditionOperatorRemoved; - - base.Dispose(disposing); - } } } \ No newline at end of file diff --git a/src/Artemis.Core/Models/Profile/DataModel/DataModelPath.cs b/src/Artemis.Core/Models/Profile/DataModel/DataModelPath.cs index 2f4ef95cf..906fcc8cb 100644 --- a/src/Artemis.Core/Models/Profile/DataModel/DataModelPath.cs +++ b/src/Artemis.Core/Models/Profile/DataModel/DataModelPath.cs @@ -56,7 +56,7 @@ namespace Artemis.Core SubscribeToDataModelStore(); } - internal DataModelPath(object target, DataModelPathEntity entity) + internal DataModelPath(object? target, DataModelPathEntity entity) { Target = target!; Path = entity.Path; diff --git a/src/Artemis.Storage/Entities/Profile/Conditions/DataModelConditionListEntity.cs b/src/Artemis.Storage/Entities/Profile/Conditions/DataModelConditionListEntity.cs index 00e6f0e34..8c8959ab4 100644 --- a/src/Artemis.Storage/Entities/Profile/Conditions/DataModelConditionListEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/Conditions/DataModelConditionListEntity.cs @@ -11,9 +11,7 @@ namespace Artemis.Storage.Entities.Profile.Conditions Children = new List(); } - public Guid? ListDataModelGuid { get; set; } - public string ListPropertyPath { get; set; } - + public DataModelPathEntity ListPath { get; set; } public int ListOperator { get; set; } } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/Conditions/DataModelConditionPredicateEntity.cs b/src/Artemis.Storage/Entities/Profile/Conditions/DataModelConditionPredicateEntity.cs index 91f39ccf2..08ee41d25 100644 --- a/src/Artemis.Storage/Entities/Profile/Conditions/DataModelConditionPredicateEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/Conditions/DataModelConditionPredicateEntity.cs @@ -6,16 +6,14 @@ namespace Artemis.Storage.Entities.Profile.Conditions public class DataModelConditionPredicateEntity : DataModelConditionPartEntity { public int PredicateType { get; set; } - public Guid? LeftDataModelGuid { get; set; } - public string LeftPropertyPath { get; set; } - - public Guid? RightDataModelGuid { get; set; } - public string RightPropertyPath { get; set; } + public DataModelPathEntity LeftPath { get; set; } + public DataModelPathEntity RightPath { get; set; } public string OperatorType { get; set; } public Guid? OperatorPluginGuid { get; set; } // Stored as a string to be able to control serialization and deserialization ourselves public string RightStaticValue { get; set; } + } } \ No newline at end of file diff --git a/src/Artemis.sln.DotSettings b/src/Artemis.sln.DotSettings index 6556f237b..382c2aef7 100644 --- a/src/Artemis.sln.DotSettings +++ b/src/Artemis.sln.DotSettings @@ -50,7 +50,7 @@ </Entry.SortBy> </Entry> <Entry DisplayName="All other members" /> - <Entry DisplayName="Test Methods" Priority="100"> + <Entry Priority="100" DisplayName="Test Methods"> <Entry.Match> <And> <Kind Is="Method" /> @@ -97,7 +97,7 @@ </Entry.Match> </Entry> <Entry DisplayName="All other members" /> - <Entry DisplayName="Test Methods" Priority="100"> + <Entry Priority="100" DisplayName="Test Methods"> <Entry.Match> <And> <Kind Is="Method" /> @@ -112,7 +112,7 @@ </Entry> </TypePattern> <TypePattern DisplayName="Default Pattern"> - <Entry DisplayName="Public Delegates" Priority="100"> + <Entry Priority="100" DisplayName="Public Delegates"> <Entry.Match> <And> <Access Is="Public" /> @@ -123,7 +123,7 @@ <Name /> </Entry.SortBy> </Entry> - <Entry DisplayName="Public Enums" Priority="100"> + <Entry Priority="100" DisplayName="Public Enums"> <Entry.Match> <And> <Access Is="Public" /> @@ -191,7 +191,7 @@ <Kind Is="Type" /> </Entry.Match> </Entry> - <Entry DisplayName="Interface Implementations" Priority="100"> + <Entry Priority="100" DisplayName="Interface Implementations"> <Entry.Match> <And> <Kind Is="Member" /> @@ -206,4 +206,9 @@ </Patterns> ERROR ERROR - ERROR \ No newline at end of file + ERROR + True + True + True + True + True \ No newline at end of file