Resolved save load issues for the nodes by chaning the unique node id to guid
Some checks failed
Build / build (push) Has been cancelled
Some checks failed
Build / build (push) Has been cancelled
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
@@ -85,7 +86,7 @@ namespace Nodify.Calculator
|
||||
Operations.WhenAdded(x =>
|
||||
{
|
||||
x.Input.WhenRemoved(RemoveConnection);
|
||||
if (!IsLoading) x.NodeId = (Operations.Count + 1).ToString();
|
||||
if (!IsLoading) x.NodeId = Guid.NewGuid().ToString("N");
|
||||
Debug.WriteLine($"Currently adding the node with node id : {x.NodeId} , Title : {x.Title}");
|
||||
if (x is CalculatorInputOperationViewModel ci)
|
||||
{
|
||||
|
||||
@@ -16,12 +16,11 @@ namespace Nodify.Calculator
|
||||
var operations = calculator.Operations;
|
||||
var connections = calculator.Connections;
|
||||
|
||||
// Ensure all nodes have IDs
|
||||
int idCounter = 1;
|
||||
// Ensure all nodes have unique IDs
|
||||
foreach (var op in operations)
|
||||
{
|
||||
if (string.IsNullOrEmpty(op.NodeId))
|
||||
op.NodeId = $"node_{idCounter++}";
|
||||
op.NodeId = Guid.NewGuid().ToString("N");
|
||||
}
|
||||
|
||||
// Serialize nodes
|
||||
|
||||
Reference in New Issue
Block a user