public static string Serialize(GraphModel graph) { if (graph == null) { throw new ArgumentNullException(nameof(graph)); } var sgraph = new SGraph { Type = StaticResolver.GetTypeName(graph.Type) }; foreach (var nodeModel in graph.Nodes) { sgraph.AddNode(nodeModel); } foreach (var connectionModel in graph.Connections) { sgraph.AddConnection(connectionModel); } sgraph.CustomSettings = graph.CustomSettings; return(Serialize(sgraph)); }
private SGraph CreateGraphToSerialize(IEnumerable <BaseNodeView> nodes, IEnumerable <BaseConnectionView> connections) { var sgraph = new SGraph { Type = _graphView.Graph.Type }; foreach (var nodeModel in nodes) { SNode sNode = nodeModel.Node; sNode.Position = nodeModel.localBound.min; sgraph.AddNode(sNode); } foreach (var connectionModel in connections) { sgraph.AddConnection(connectionModel.Connection); } return(sgraph); }