Node
References[DebuggerDisplay("{Topology}")]
public sealed class Node : IBinary, ISml, IWriter, IReader, IEquatable<Node>
Nodes are the main organising entities in Grasshopper IO hierarchical dictionaries. Nodes may contain any number of uniquely named items, as well as any number of uniquely named child nodes. Nodes explicitly implement the IWriter and IReader interfaces, which is how nodes are most commonly exposed to client code.
Nodes are not thread-safe, not even for reading, since lookups and the inflation of serialised child nodes modify internal state.
Fields
IoVersionNumber
#Represents the current IO version. When a breaking change to the data layout of GrasshopperIO archives must be implemented, this version will increment. I'm guessing 255 breaking changes will suffice for the lifetime of the Grasshopper 2 project, but if need be 255 can indicate a larger versioning integers stored subsequently.
Properties
Methods
AddItem
#Add a new item to this node. Item location must be unique.
AddSerialisedNode
#Add a child node from its binary form, as produced by IO.WriteNodeToByteArray, without deserialising it. The child takes the name stored in the bytes. The bytes are written verbatim when this node is written in binary form, and must not contain file paths, which are made relative to the location being written to. This method allows for speedups in repeated serialisation of the same data.
Parameters:
| bytes (byte[]) | Binary form of a node. |
AllTypeIdentifiers
#Collect all the type identifiers associated with IStorable types which have been stored in this node, and all its children and grand-children.
AreIndentical
#Test two nodes for equality. This comparison tests both the location, children and items of the node.
Parameters:
| a (Node) | First node. |
| b (Node) | Second node. |
| level (EqualityLevel) | Identity strictness. |
| recursive (bool) | If true, child nodes must also be identical. |
Returns: True if nodes are identical.
Boolean
#BooleanArray
#Implements: BooleanArray
Complex128
#Implements: Complex128
Create
#Create a loose node which contains a single storable object.
DateTime
#Decimal128
#Implements: Decimal128
EmitNode
#Add a new child to this node. The node name+index may not collide with another child already part of this node.
Parameters:
| name (Name) | Name of node to emit. |
EnumerateAndExecute
#public void EnumerateAndExecute(object incomingToken = null, NodeMethod nodeMethod = null, ItemMethod itemMethod = null)
Enumerate over all child nodes and items in this node and invoke a delegate for each.
Parameters:
| incomingToken (object = null) | Token to use for first level invokes. |
| nodeMethod (NodeMethod = null) | Method for handling all nodes. |
| itemMethod (ItemMethod = null) | Method for handling all items. |
FindChildren
#Find all children with matching names. This includes immediate children, grand-children etc. Results are returned in a breadth-first manner.
Parameters:
| name (Name) |
FindChildren
#Find all children whose name matches a predicate. This includes immediate children, grand-children etc. Results are returned in a breadth-first manner.
FindDifferences
#public static Differences FindDifferences(Node a, Node b, EqualityLevel level, params NodeMatcher[] matchers)
Find the differences between two nodes.
Parameters:
| a (Node) | First node. |
| b (Node) | Second node. |
| level (EqualityLevel) | Level of comparison for differences. |
| matchers (params NodeMatcher[]) | Matchers to apply. |
FindItem
#Get the value associated with the specified location.
FindNode
#Get the child with the specified name and index.
Parameters:
| name (Name) | Name of node to retrieve. |
Returns: The node with the given name and index or null if no such node exists.
FindParents
#Find all parents with matching names. The nearest parent is returned first.
Parameters:
| name (Name) |
GetHashCode
#Gets the hash code for this node. Note that nodes are mutable and that this method is *not* threadsafe. You should never rely on node hashes if you suspect some thread other than the caller may be affecting this node or any of the child nodes. Also note that the hash does not include any of the messaging strings.
Overrides: Object.GetHashCode
Explicit implementation of ISerializable.Read. Use the static methods on the IO class to deserialize nodes correctly and with a minimum of effort.
Parameters:
| reader (BinaryReader) | |
| context (ReadContext) |
Implements: Read
Explicit implementation of IBinary.Write(BinaryWriter, WriteContext). Use the static methods on the IO class to serialize nodes correctly and with a minimum of effort.
Parameters:
| writer (BinaryWriter) | |
| context (WriteContext) |
Implements: Write
Explicit implementation of IBinary.Write(BinaryWriter, WriteContext). Use the static methods on the IO class to serialize nodes correctly and with a minimum of effort.
Parameters:
| writer (SmlWriter) | |
| context (WriteContext) |
Implements: Write
Parameters:
| name (Name) |
Implements: FindReader
Parameters:
| name (Name) |
Implements: GenericArray
Parameters:
| name (Name) |
Implements: CreateWriter
Parameters:
| name (Name) | |
| array (T[]) |
Implements: GenericArray
Guid128
#GuidArray
#HasItem
#Test to see whether an item with a specific name and index has been defined in this node.
HasItem
#Test to see whether an item with a specific name and index has been defined in this node.
HasItemOrNode
#Gets whether the specified location is available as either an item or a node.
Parameters:
| name (Name) |
Implements: HasItemOrNode
HasNode
#Test to see whether a child with a specific name and index has been defined in this node.
Integer32
#Integer32Array
#Parameters:
| name (Name) |
Implements: Integer32Array
Integer32Array
#Implements: Integer32Array
Integer64
#Integer64Array
#Parameters:
| name (Name) |
Implements: Integer64Array
Integer64Array
#Implements: Integer64Array
Integer8
#Integer8Array
#Implements: Integer8Array
Number32
#Number32Array
#Parameters:
| name (Name) |
Implements: Number32Array
Number32Array
#Implements: Number32Array
Number64
#Number64Array
#Parameters:
| name (Name) |
Implements: Number64Array
Number64Array
#Implements: Number64Array
ReplaceItem
#Replace an existing item, or add it if it doesn't exist yet.
Parameters:
| item (Item) | New item value. |
Select
#Try and find a node in this hierarchy.
Parameters:
| path (string) | Path to child or grand-child. Must be a comma separated list of names. |
Returns: Child node if found, otherwise null.
Storable
#String
#StringArray
#Implements: StringArray
TimeSpan
#ToString
#Returns a string that represents the current object.
Returns: A string that represents the current object.
Overrides: Object.ToString
TryFindChild
#Try and find the child node which is reached via the given path.
Parameters:
| path (params Name[]) |
TryFindParent
#Try and find the parent node which is reached via the given path.
Parameters:
| path (params Name[]) |