Exemplo n.º 1
0
 public PrtgNodeDebugView(PrtgNode <TValue> node)
 {
     this.node = node;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Retrieves the single node that matches a specified predicate from the descendants of a <see cref="PrtgNode"/>.<para/>
 /// If no matches are found, this method returns null. If multiple matches are found, an <see cref="InvalidOperationException"/> is thrown.
 /// </summary>
 /// <param name="root">The node whose tree should be searched.</param>
 /// <param name="predicate">The condition to filter by.</param>
 /// <exception cref="InvalidOperationException">Multiple nodes matched the specified predicate.</exception>
 /// <returns>If a single node matched the predicate, the node that matched the predicate. Otherwise, null.</returns>
 public static PrtgNode FindNode(this PrtgNode root, Func <PrtgNode, bool> predicate) =>
 FindNode <PrtgNode>(root, predicate);
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProbeNode"/> class with the orphan this node encapsulates and the parent of this node.
 /// </summary>
 /// <param name="orphan">The orphan this node encapsulates.</param>
 /// <param name="parent">The parent of this node.</param>
 internal ProbeNode(ProbeOrphan orphan, PrtgNode parent) : base(orphan, parent)
 {
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new <see cref="PrtgNode"/> with a collection of nodes inserted before a specified node.
 /// </summary>
 /// <typeparam name="TRoot">The type of the root node.</typeparam>
 /// <param name="root">The root of the tree of nodes.</param>
 /// <param name="nodeInList">The descendant of <paramref name="root"/> the new nodes should be inserted before.</param>
 /// <param name="newNodes">The new nodes to insert before the <paramref name="nodeInList"/> that will become children of the <paramref name="nodeInList"/>'s parent.</param>
 /// <returns>A new node with the specified nodes inserted at the specified position.</returns>
 public static TRoot InsertNodesBefore <TRoot>(this TRoot root, PrtgNode nodeInList, IEnumerable <PrtgNode> newNodes) where TRoot : PrtgNode =>
 (TRoot) new PrtgNodeListEditor(nodeInList, newNodes, ListEditType.InsertBefore).Visit(root);
Exemplo n.º 5
0
 /// <summary>
 /// Creates a new <see cref="PrtgNode"/> with a single descendant <see cref="PrtgNode"/> replaced with a collection of nodes.
 /// </summary>
 /// <typeparam name="TRoot">The type of the root node.</typeparam>
 /// <param name="root">The node to replace descendant nodes of.</param>
 /// <param name="oldNode">The existing node to replace.</param>
 /// <param name="newNodes">The new nodes to replace the existing node with.</param>
 /// <returns>A new node with the specified descendant node replaced.</returns>
 public static TRoot ReplaceNodes <TRoot>(this TRoot root, PrtgNode oldNode, params PrtgNode[] newNodes) where TRoot : PrtgNode =>
 root.ReplaceNodes(oldNode, (IEnumerable <PrtgNode>)newNodes);
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeviceNode"/> class with the orphan this node encapsulates and the parent of this node.
 /// </summary>
 /// <param name="orphan">The orphan this node encapsulates.</param>
 /// <param name="parent">The parent of this node.</param>
 internal DeviceNode(DeviceOrphan orphan, PrtgNode parent) : base(orphan, parent)
 {
 }
Exemplo n.º 7
0
 /// <summary>
 /// Creates a new <see cref="PrtgNode"/> with a new node inserted before a specified node.
 /// </summary>
 /// <typeparam name="TRoot">The type of the root node.</typeparam>
 /// <param name="root">The root of the tree of nodes.</param>
 /// <param name="nodeInList">The descendant of <paramref name="root"/> the new node should be inserted before.</param>
 /// <param name="newNode">The new node to insert before the <paramref name="nodeInList"/> that will become a child of the <paramref name="nodeInList"/>'s parent.</param>
 /// <returns>A new node with the specified node inserted at the specified position.</returns>
 public static TRoot InsertNodeBefore <TRoot>(this TRoot root, PrtgNode nodeInList, PrtgNode newNode) where TRoot : PrtgNode =>
 root.InsertNodesBefore(nodeInList, new[] { newNode });
Exemplo n.º 8
0
 /// <summary>
 /// Creates a <see cref="DeviceNode"/> for a device with a specified ID.<para/>
 /// If the device does not exist or an ambiguous match is found, an <see cref="InvalidOperationException"/> is thrown.
 /// </summary>
 /// <param name="id">The ID of the device to retrieve.</param>
 /// <param name="children">The children of this node.</param>
 /// <exception cref="InvalidOperationException">The specified device does not exist or multiple devices were resolved with the specified ID.</exception>
 /// <returns>A <see cref="DeviceNode"/> encapsulating the specified object.</returns>
 public DeviceNode Device(int id, IEnumerable <PrtgNode> children) =>
 PrtgNode.Device(client.GetDevice(id), children);
Exemplo n.º 9
0
 /// <summary>
 /// Creates a <see cref="GroupNode"/> for a group with a specified ID.<para/>
 /// If the group does not exist or an ambiguous match is found, an <see cref="InvalidOperationException"/> is thrown.
 /// </summary>
 /// <param name="id">The ID of the group to retrieve.</param>
 /// <param name="children">The children of this node.</param>
 /// <exception cref="InvalidOperationException">The specified group does not exist or multiple groups were resolved with the specified ID.</exception>
 /// <returns>A <see cref="GroupNode"/> encapsulating the specified object.</returns>
 public GroupNode Group(int id, IEnumerable <PrtgNode> children) =>
 PrtgNode.Group(client.GetGroup(id), children);
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GroupNode"/> class with the orphan this node encapsulates and the parent of this node.
 /// </summary>
 /// <param name="orphan">The orphan this node encapsulates.</param>
 /// <param name="parent">The parent of this node.</param>
 internal GroupNode(GroupOrphan orphan, PrtgNode parent) : base(orphan, parent)
 {
 }
Exemplo n.º 11
0
 /// <summary>
 /// Visits a single <see cref="PrtgNode"/>.
 /// </summary>
 /// <param name="node">The node to visit.</param>
 public virtual void Visit(PrtgNode node) => node.Accept(this);
Exemplo n.º 12
0
 internal TriggerNodeCollection(TriggerOrphanCollection orphan, PrtgNode parent) : base(orphan, parent)
 {
 }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PropertyNode"/> class with the orphan this node encapsulates and the parent of this node.
 /// </summary>
 /// <param name="orphan">The orphan this node encapsulates.</param>
 /// <param name="parent">The parent of this node.</param>
 internal PropertyNode(PropertyOrphan orphan, PrtgNode parent) : base(orphan, parent)
 {
 }
Exemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TriggerNode"/> class with the orphan this node encapsulates and the parent of this node.
 /// </summary>
 /// <param name="orphan">The orphan this node encapsulates.</param>
 /// <param name="parent">The parent of this node.</param>
 internal TriggerNode(TriggerOrphan orphan, PrtgNode parent) : base(orphan, parent)
 {
 }
Exemplo n.º 15
0
 internal CompareTreeVisitor(PrtgNode first, TreeNodeDifference[] interestedDifferences)
 {
     this.first = first;
     this.interestedDifferences = interestedDifferences;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Creates a <see cref="ProbeNode"/> for a probe with a specified ID.<para/>
 /// If the probe does not exist or an ambiguous match is found, an <see cref="InvalidOperationException"/> is thrown.
 /// </summary>
 /// <param name="id">The ID of the probe to retrieve.</param>
 /// <param name="children">The children of this node.</param>
 /// <exception cref="InvalidOperationException">The specified probe does not exist or multiple probes were resolved with the specified ID.</exception>
 /// <returns>A <see cref="ProbeNode"/> encapsulating the specified object.</returns>
 public ProbeNode Probe(int id, IEnumerable <PrtgNode> children) =>
 PrtgNode.Probe(client.GetProbe(id), children);
Exemplo n.º 17
0
 protected override CompareOrphan DefaultVisit(PrtgNode node) => Visit(node);
Exemplo n.º 18
0
 /// <summary>
 /// Creates a <see cref="PropertyNode"/> for all properties of a specified object.
 /// </summary>
 /// <param name="objectOrId">The object to retrieve the properties from.</param>
 /// <returns>A list of <see cref="PropertyNode"/> objects encapsulating the returned properties.</returns>
 public List <PropertyNode> Properties(Either <IPrtgObject, int> objectOrId) =>
 client.GetObjectPropertiesRaw(objectOrId).Select(kv => PrtgNode.Property(objectOrId, kv.Key, kv.Value)).ToList();
Exemplo n.º 19
0
 /// <summary>
 /// Creates a new <see cref="PrtgNode"/> with a new node inserted after a specified node.
 /// </summary>
 /// <typeparam name="TRoot">The type of the root node.</typeparam>
 /// <param name="root">The root of the tree of nodes.</param>
 /// <param name="nodeInList">The descendant of <paramref name="root"/> the new node should be inserted after.</param>
 /// <param name="newNode">The new node to insert after the <paramref name="nodeInList"/> that will become a child of the <paramref name="nodeInList"/>'s parent.</param>
 /// <returns>A new node with the specified node inserted at the specified position.</returns>
 public static TRoot InsertNodeAfter <TRoot>(this TRoot root, PrtgNode nodeInList, PrtgNode newNode) where TRoot : PrtgNode =>
 root.InsertNodesAfter(nodeInList, new[] { newNode });
Exemplo n.º 20
0
 /// <summary>
 /// Creates a <see cref="SensorNode"/> for a sensor with a specified ID.<para/>
 /// If the sensor does not exist or an ambiguous match is found, an <see cref="InvalidOperationException"/> is thrown.
 /// </summary>
 /// <param name="id">The ID of the sensor to retrieve.</param>
 /// <param name="children">The children of this node.</param>
 /// <exception cref="InvalidOperationException">The specified sensor does not exist or multiple sensors were resolved with the specified ID.</exception>
 /// <returns>A <see cref="SensorNode"/> encapsulating the specified object.</returns>
 public SensorNode Sensor(int id, IEnumerable <PrtgNode> children) =>
 PrtgNode.Sensor(client.GetSensor(id), children);
Exemplo n.º 21
0
 /// <summary>
 /// Creates a new <see cref="PrtgNode"/> with a collection of nodes inserted before a specified node.
 /// </summary>
 /// <typeparam name="TRoot">The type of the root node.</typeparam>
 /// <param name="root">The root of the tree of nodes.</param>
 /// <param name="nodeInList">The descendant of <paramref name="root"/> the new nodes should be inserted before.</param>
 /// <param name="newNodes">The new nodes to insert before the <paramref name="nodeInList"/> that will become children of the <paramref name="nodeInList"/>'s parent.</param>
 /// <returns>A new node with the specified nodes inserted at the specified position.</returns>
 public static TRoot InsertNodesBefore <TRoot>(this TRoot root, PrtgNode nodeInList, params PrtgNode[] newNodes) where TRoot : PrtgNode =>
 root.InsertNodesBefore(nodeInList, (IEnumerable <PrtgNode>)newNodes);
Exemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SensorNode"/> class with the orphan this node encapsulates and the parent of this node.
 /// </summary>
 /// <param name="orphan">The orphan this node encapsulates.</param>
 /// <param name="parent">The parent of this node.</param>
 internal SensorNode(SensorOrphan orphan, PrtgNode parent) : base(orphan, parent)
 {
 }
Exemplo n.º 23
0
 /// <summary>
 /// Creates a new <see cref="PrtgNode"/> with specified descendant node removed.
 /// </summary>
 /// <typeparam name="TRoot">The type of the root node.</typeparam>
 /// <param name="root">The node to remove descendant nodes from.</param>
 /// <param name="node">The node to remove. If this value is empty or null, no node will be removed.</param>
 /// <returns>If any nodes were specified, a new node with those descendants removed. Otherwise, the original node.</returns>
 public static TRoot RemoveNode <TRoot>(this TRoot root, PrtgNode node) where TRoot : PrtgNode =>
 RemoveNodes(root, node);
Exemplo n.º 24
0
 internal PropertyNodeCollection(PropertyOrphanCollection orphan, PrtgNode parent) : base(orphan, parent)
 {
 }
Exemplo n.º 25
0
 /// <summary>
 /// Creates a new <see cref="PrtgNode"/> with a single descendant <see cref="PrtgNode"/> replaced with a collection of nodes.
 /// </summary>
 /// <typeparam name="TRoot">The type of the root node.</typeparam>
 /// <param name="root">The node to replace descendant nodes of.</param>
 /// <param name="oldNode">The existing node to replace.</param>
 /// <param name="newNodes">The new nodes to replace the existing node with.</param>
 /// <returns>A new node with the specified descendant node replaced.</returns>
 public static TRoot ReplaceNodes <TRoot>(this TRoot root, PrtgNode oldNode, IEnumerable <PrtgNode> newNodes) where TRoot : PrtgNode =>
 (TRoot) new PrtgNodeListEditor(oldNode, newNodes, ListEditType.Replace).Visit(root);
Exemplo n.º 26
0
 internal PrtgNodeListEditor(PrtgNode oldNode, IEnumerable <PrtgNode> nodes, ListEditType type)
 {
     this.oldNode  = oldNode;
     this.newNodes = nodes;
     this.type     = type;
 }
Exemplo n.º 27
0
 /// <summary>
 /// Retrieves all nodes that match a specified predicate from the descendants of a <see cref="PrtgNode"/>.
 /// </summary>
 /// <param name="root">The node whose tree should be searched.</param>
 /// <param name="predicate">The condition to filter by.</param>
 /// <returns>A collection of nodes that matched the specified predicate.</returns>
 public static IEnumerable <PrtgNode> FindNodes(this PrtgNode root, Func <PrtgNode, bool> predicate) =>
 FindNodes <PrtgNode>(root, predicate);
Exemplo n.º 28
0
 /// <summary>
 /// The action to perform for all nodes whose visitor method is not overridden.
 /// </summary>
 /// <param name="node">The node to visit.</param>
 protected abstract void DefaultVisit(PrtgNode node);