public void SerializeCache(Graph graph) { Graph.SerializedData serializedData = new Graph.SerializedData(graph); serializedData.States.Clear(); serializedData.AnyStates.Clear(); foreach (var node in Nodes) { if (node is State state) { serializedData.States.Add(state); } else if (node is AnyState anyState) { serializedData.AnyStates.Add(anyState); } } serializedData.Transitions.Clear(); foreach (var transition in Transitions) { serializedData.Transitions.Add(transition); } }
void CacheTransitions(Graph.SerializedData serializedData) { Transitions.Clear(); foreach (var transition in serializedData.Transitions) { Transitions.Add(transition); } }
public void BuildCache(Graph graph) { Graph.SerializedData serializedData = new Graph.SerializedData(graph); CacheNodes(serializedData); CacheTransitions(serializedData); BuildNodeDictionary(); BuildTransitionDictionary(); }
void CacheNodes(Graph.SerializedData serializedData) { Nodes.Clear(); foreach (var node in serializedData.States) { Nodes.Add(node); } foreach (var node in serializedData.AnyStates) { Nodes.Add(node); } }