/// <inheritdoc /> protected override void InitializeRightPath() { if (PredicateType == ProfileRightSideType.Dynamic && Entity.RightPath != null) { RightPath = new DataModelPath(null, Entity.RightPath); } }
/// <inheritdoc /> protected override void InitializeLeftPath() { if (Entity.LeftPath != null) { LeftPath = new DataModelPath(null, Entity.LeftPath); } }
internal DataModelPathSegment(DataModelPath dataModelPath, string identifier, string path) { DataModelPath = dataModelPath; Identifier = identifier; Path = path; IsStartSegment = !DataModelPath.Segments.Any(); }
private void DynamicDataModelOnDynamicDataModelAdded(object?sender, DynamicDataModelEventArgs e) { if (e.Key == Identifier) { DataModelPath.Initialize(); } }
private void DynamicChildOnDynamicChildRemoved(object?sender, DynamicDataModelChildEventArgs e) { if (e.DynamicChild.BaseValue == _dynamicDataModel) { DataModelPath.Initialize(); } }
private void DynamicDataModelOnDynamicDataModelRemoved(object?sender, DynamicDataModelEventArgs e) { if (e.DynamicDataModel == _dynamicDataModel) { DataModelPath.Initialize(); } }
private object?GetListPathValue(DataModelPath path, object target) { if (!(path.Target is ListPredicateWrapperDataModel wrapper)) { throw new ArtemisCoreException("Data model condition list predicate has a path with an invalid target"); } wrapper.UntypedValue = target; return(path.GetValue()); }
private bool PointsToEvent(DataModelPath dataModelPath) { Type?type = dataModelPath.GetPropertyType(); if (type == null) { return(false); } return(typeof(IDataModelEvent).IsAssignableFrom(type)); }
private object?GetEventPathValue(DataModelPath path, object?target) { lock (path) { if (!(path.Target is EventPredicateWrapperDataModel wrapper)) { throw new ArtemisCoreException("Data model condition event predicate has a path with an invalid target"); } wrapper.UntypedArguments = target; return(path.GetValue()); } }
/// <inheritdoc /> public void Load() { // Source if (Entity.SourcePath != null) { SourcePath = new DataModelPath(null, Entity.SourcePath); } // Modifiers foreach (DataBindingModifierEntity dataBindingModifierEntity in Entity.Modifiers) { _modifiers.Add(new DataBindingModifier <TLayerProperty, TProperty>(this, dataBindingModifierEntity)); } ApplyOrder(); }
/// <summary> /// Creates a new instance of the <see cref="DataModelPath" /> class based on an existing path /// </summary> /// <param name="dataModelPath">The path to base the new instance on</param> public DataModelPath(DataModelPath dataModelPath) { if (dataModelPath == null) { throw new ArgumentNullException(nameof(dataModelPath)); } Target = dataModelPath.Target; Path = dataModelPath.Path; Entity = new DataModelPathEntity(); _segments = new LinkedList <DataModelPathSegment>(); Save(); Initialize(); SubscribeToDataModelStore(); }
private void Initialize() { DataBindingModifierTypeStore.DataBindingModifierAdded += DataBindingModifierTypeStoreOnDataBindingModifierAdded; DataBindingModifierTypeStore.DataBindingModifierRemoved += DataBindingModifierTypeStoreOnDataBindingModifierRemoved; // Modifier type if (Entity.ModifierTypePluginGuid != null && ModifierType == null) { BaseDataBindingModifierType?modifierType = DataBindingModifierTypeStore.Get(Entity.ModifierTypePluginGuid.Value, Entity.ModifierType)?.DataBindingModifierType; if (modifierType != null) { UpdateModifierType(modifierType); } } // Dynamic parameter if (ParameterType == ProfileRightSideType.Dynamic && Entity.ParameterPath != null) { ParameterPath = new DataModelPath(null, Entity.ParameterPath); } // Static parameter else if (ParameterType == ProfileRightSideType.Static && Entity.ParameterStaticValue != null) { // Use the target type so JSON.NET has a better idea what to do Type? parameterType = ModifierType?.ParameterType ?? DirectDataBinding.DataBinding.GetTargetType(); object?staticValue = null; try { staticValue = parameterType != null ? CoreJson.DeserializeObject(Entity.ParameterStaticValue, parameterType) : CoreJson.DeserializeObject(Entity.ParameterStaticValue); } // If deserialization fails, use the type's default catch (JsonSerializationException e) { DeserializationLogger.LogModifierDeserializationFailure(GetType().Name, e); if (parameterType != null) { staticValue = Activator.CreateInstance(parameterType); } } UpdateParameterStatic(staticValue); } }
/// <inheritdoc /> protected override void InitializeRightPath() { if (PredicateType == ProfileRightSideType.Dynamic && Entity.RightPath != null) { // Right side dynamic inside the list if (Entity.RightPath.WrapperType == PathWrapperType.List) { RightPath = DataModelConditionList.ListType != null ? new DataModelPath(ListPredicateWrapperDataModel.Create(DataModelConditionList.ListType), Entity.RightPath) : null; } // Right side dynamic else { RightPath = new DataModelPath(null, Entity.RightPath); } } }
/// <inheritdoc /> protected override void InitializeRightPath() { if (PredicateType == ProfileRightSideType.Dynamic && Entity.RightPath != null) { // Right side dynamic using event arguments if (Entity.RightPath.WrapperType == PathWrapperType.Event) { RightPath = DataModelConditionEvent.EventArgumentType != null ? new DataModelPath(EventPredicateWrapperDataModel.Create(DataModelConditionEvent.EventArgumentType), Entity.RightPath) : null; } // Right side dynamic else { RightPath = new DataModelPath(null, Entity.RightPath); } } }
internal void Initialize() { ConditionOperatorStore.ConditionOperatorAdded += ConditionOperatorStoreOnConditionOperatorAdded; ConditionOperatorStore.ConditionOperatorRemoved += ConditionOperatorStoreOnConditionOperatorRemoved; // Left side 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; if (conditionOperator != null) { UpdateOperator(conditionOperator); } } // Right side dynamic 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 (LeftPath != null && LeftPath.IsValid) { // Use the left side type so JSON.NET has a better idea what to do Type leftSideType = LeftPath.GetPropertyType() !; object?rightSideValue; try { rightSideValue = JsonConvert.DeserializeObject(Entity.RightStaticValue, leftSideType); } // If deserialization fails, use the type's default catch (JsonSerializationException e) { DeserializationLogger.LogPredicateDeserializationFailure(this, e); rightSideValue = Activator.CreateInstance(leftSideType); } UpdateRightSideStatic(rightSideValue); } else { // Hope for the best... UpdateRightSideStatic(JsonConvert.DeserializeObject(Entity.RightStaticValue)); } } catch (JsonReaderException) { // ignored // TODO: Some logging would be nice } } }
private void Initialize() { ConditionOperatorStore.ConditionOperatorAdded += ConditionOperatorStoreOnConditionOperatorAdded; ConditionOperatorStore.ConditionOperatorRemoved += ConditionOperatorStoreOnConditionOperatorRemoved; // Left side if (Entity.LeftPath != null) { LeftPath = DataModelConditionList.ListType != null ? new DataModelPath(ListPredicateWrapperDataModel.Create(DataModelConditionList.ListType), Entity.LeftPath) : null; } // Operator if (Entity.OperatorPluginGuid != null) { ConditionOperator?conditionOperator = ConditionOperatorStore.Get(Entity.OperatorPluginGuid.Value, Entity.OperatorType)?.ConditionOperator; if (conditionOperator != null) { UpdateOperator(conditionOperator); } } // Right side dynamic if (PredicateType == ProfileRightSideType.Dynamic && Entity.RightPath != null) { // Right side dynamic inside the list // TODO: Come up with a general wrapper solution because this will clash with events if (Entity.RightPath.DataModelGuid == Constants.CorePluginInfo.Guid) { RightPath = DataModelConditionList.ListType != null ? new DataModelPath(ListPredicateWrapperDataModel.Create(DataModelConditionList.ListType), Entity.RightPath) : null; } // Right side dynamic else { RightPath = new DataModelPath(null, Entity.RightPath); } } // Right side static else if (PredicateType == ProfileRightSideType.Static && Entity.RightStaticValue != null) { try { if (LeftPath != null && LeftPath.IsValid) { // Use the left side type so JSON.NET has a better idea what to do Type leftSideType = LeftPath.GetPropertyType() !; object?rightSideValue; try { rightSideValue = JsonConvert.DeserializeObject(Entity.RightStaticValue, leftSideType); } // If deserialization fails, use the type's default catch (JsonSerializationException e) { DeserializationLogger.LogListPredicateDeserializationFailure(this, e); rightSideValue = Activator.CreateInstance(leftSideType); } UpdateRightSideStatic(rightSideValue); } else { // Hope for the best... we must infer the type from JSON now UpdateRightSideStatic(JsonConvert.DeserializeObject(Entity.RightStaticValue)); } } catch (JsonException e) { DeserializationLogger.LogListPredicateDeserializationFailure(this, e); } } }
public DataModelValueChangedEvent(DataModelPath path) { Path = path; }