コード例 #1
0
 /// <summary>
 /// Sets the current value of the graph node.
 /// </summary>
 /// <param name="value">The value to set for the graph node content.</param>
 /// <remarks>This method can be invoked from a property setter.</remarks>
 /// <remarks>This method will invoke the delegates passed to the constructor of this instance if the new value is different from the previous one.</remarks>
 public void SetNodeValue(TTargetType value)
 {
     using (var transaction = actionService?.CreateTransaction())
     {
         node.Update(converter(value));
         actionService?.SetName(transaction, $"Update property {propertyName}");
     }
 }
コード例 #2
0
 /// <summary>
 /// Setter for the virtual node's value.
 /// </summary>
 /// <param name="undoRedoService"></param>
 /// <param name="propertyContainerNode">The node containing the property.</param>
 /// <param name="propertyIndex">The index of the property in the node.</param>
 /// <param name="value">The value to set.</param>
 private static void Setter(IUndoRedoService undoRedoService, [NotNull] IObjectNode propertyContainerNode, NodeIndex propertyIndex, object value)
 {
     using (undoRedoService?.CreateTransaction())
     {
         if (!propertyContainerNode.Indices.Contains(propertyIndex))
         {
             // Note: update would probably work, but we want to remove the property when Undo
             propertyContainerNode.Add(value, propertyIndex);
         }
         else
         {
             propertyContainerNode.Update(value, propertyIndex);
         }
     }
 }