private void BuildTree(List <Node> Nodes) { foreach (var node in Nodes) { if (NodesDictionary.ContainsKey(node.ID)) { throw new Exception("Node " + node.ID + " already exists."); } NodesDictionary[node.ID] = node; } foreach (var node in Nodes) { if (!node.IsRoot) { if (!NodesDictionary.ContainsKey(node.ParentID)) { throw new Exception("Node " + node.ParentID + " not exists."); } node.Parent = NodesDictionary[node.ParentID]; node.Parent.Childs.Add(node); } else { RootNodes.Add(node); node.Parent = null; } } }
/// <summary> /// Returns the beginning of the dialog. Is this function returns null, then the dialog is probably corrupted /// unless you are doing some veeeeeeery special operations on it. /// </summary> /// <returns>Returns the beginning of the dialog.</returns> public DialogBeginningWireNode GetBeginning() { if (NodesDictionary.ContainsKey(1)) { return(NodesDictionary[1] as DialogBeginningWireNode); } return(null); }
/// <summary> /// Unloads the dialog: it first calls the <see cref="ILoadable.Unload"/> function of all the nodes implementing the /// <see cref="ILoadable"/> interface. Then, it clears the nodes and the pins maps. /// </summary> public void Unload() { foreach (WireNode node in NodesDictionary.Values) { if (node is ILoadable) { (node as ILoadable).Unload(); } } NodesDictionary.Clear(); Pins.Clear(); }
//What is the purpose of this method? If someone wanted to clear the Model, they could just create a new one. public void Clear() { Loads.Clear(); ClustersDictionary.Clear(); SubdomainsDictionary.Clear(); ElementsDictionary.Clear(); NodesDictionary.Clear(); GlobalDofOrdering = null; Constraints.Clear(); ElementMassAccelerationHistoryLoads.Clear(); ElementMassAccelerationLoads.Clear(); MassAccelerationHistoryLoads.Clear(); MassAccelerationLoads.Clear(); }
/// <summary> /// Returns the node with the specified name. /// </summary> public BaseNode GetNode(string identifier) { if (string.IsNullOrEmpty(identifier)) { return(null); } BaseNode node; if (NodesDictionary.TryGetValue(identifier, out node)) { return(node); } else { throw new KeyNotFoundException(string.Format("Dialogue '{0}' has no node '{1}'", name, identifier)); } }