Class NodesManager<T>
- Namespace
- WitShells.DesignPatterns.Core
A simple list-backed INodeManager<T> that stores nodes in insertion order. Duplicate nodes (by reference) are rejected.
public class NodesManager<T> : INodeManager<T>
Type Parameters
TThe node data type.
- Inheritance
-
NodesManager<T>
- Implements
-
INodeManager<T>
- Inherited Members
Methods
AddNode(NodeController<T>)
Adds a node to the collection. Returns true on success.
public bool AddNode(NodeController<T> node)
Parameters
nodeNodeController<T>
Returns
Clear()
Removes all nodes and disposes each one.
public void Clear()
FromJson(string)
Deserialises and replaces the collection from a JSON string.
public virtual void FromJson(string json)
Parameters
jsonstring
GetAllNodes()
Returns an enumerable of all nodes currently in the collection.
public IEnumerable<NodeController<T>> GetAllNodes()
Returns
GetNode(Func<T, bool>)
Returns the first node value that satisfies predicate, or default.
public virtual T GetNode(Func<T, bool> predicate)
Parameters
Returns
- T
GetNode(T)
public NodeController<T> GetNode(T value)
Parameters
valueT
Returns
RemoveNode(NodeController<T>)
Removes a node from the collection. Returns true on success.
public bool RemoveNode(NodeController<T> node)
Parameters
nodeNodeController<T>
Returns
RemoveWhere(Func<T, bool>)
Removes all nodes whose data satisfies predicate.
public void RemoveWhere(Func<T, bool> predicate)
Parameters
ToJson()
Serialises the collection to a JSON string.
public virtual string ToJson()