/// <summary> /// Overridden to create DOM nodes from the decoded TLV. /// In derived classes, override the OnNewContainer(EmberNode) /// overload. /// </summary> protected override sealed void OnNewContainer() { Debug.Assert(_currentNode == null || _currentNode is EmberContainer); var container = EmberNode.FromReader(this, _application); Debug.Assert(container != null); if (IsRootReady) { Debug.Assert(_rootNode != null); Debug.Assert(_currentNode == null); _rootNode = null; IsRootReady = false; } if (_rootNode == null) { Debug.Assert(_currentNode == null); _rootNode = container; } else { Debug.Assert(_currentNode != null); _currentNode.InsertChildNode(container); } _currentNode = container; OnNewContainer(container); }
/// <summary> /// Inserts a node into this node's collection of children. /// </summary> /// <param name="node">The node to insert.</param> protected internal override void InsertChildNode(EmberNode node) { if (node == null) { throw new ArgumentNullException("node"); } var nodeLength = node.EncodedLength; node.Parent = this; _nodes.AddLast(node); MarkDirty(); }
protected internal override void InsertChildNode(EmberNode node) { Debug.Assert(node != null); if (IsMapUsed) { var tag = node.Tag; if (_nodesMap.ContainsKey(tag)) { throw new BerException(1001, "A node with the specified tag already exists in this container"); } _nodesMap[tag] = node; } InsertChildNodeBase(node); }
/// <summary> /// Overridden to create DOM nodes from the decoded TLV. /// In derived classes, override the OnItemReady(EmberNode) /// overload. /// </summary> protected override sealed void OnItemReady() { Debug.Assert(_rootNode != null); Debug.Assert(_currentNode != null); if (IsContainer) { EmberNode readyNode; if (_currentNode == _rootNode) { IsRootReady = true; OnRootReady(new RootReadyArgs(_currentNode)); readyNode = _currentNode; _currentNode = null; } else { readyNode = _currentNode; _currentNode = _currentNode.Parent; } RaiseItemReady(readyNode); } else { var node = EmberNode.FromReader(this, _application); if (node != null) { _currentNode.InsertChildNode(node); RaiseItemReady(node); } } }
/// <summary> /// Inserts a node into this node's collection of children. /// Overriden to throws an exception because this node is not a container. /// </summary> /// <param name="node">The node to insert.</param> protected internal override sealed void InsertChildNode(EmberNode node) { throw new BerException(3, Error_NotAContainer); }
internal void RaiseValidationError(EmberNode node, string message) { OnValidationError(new ValidationErrorArgs(node, message)); }
public ValidationErrorArgs(EmberNode node, string message) { Node = node; Message = message; }
public RootReadyArgs(EmberNode root) { Root = root; }
void RaiseItemReady(EmberNode node) { node.ValidateAfterDecode(); OnItemReady(node); }
/// <summary> /// Called when a TLV (either container or primitive) has been decoded. /// The read TLV can be examined through <paramref name="node"/>. /// </summary> /// <param name="node">An EmberNode object containing the decoded information. /// This object is ready for use, all significant properties (like Tag, Parent, Type) /// have valid values. /// You can use the EmberNode.Accept() method to pass an IEmberVisitor implementation to /// examine the node.</param> protected virtual void OnItemReady(EmberNode node) { }
/// <summary> /// Called when the opening tag and length of a new container have been /// read. /// The opened container can be accessed through <paramref name="node" />. /// </summary> /// <param name="node">The newly created EmberNode to hold the container's children. /// The children will not be included in the node until OnItemReady(EmberNode) is /// called. /// You can use the EmberNode.Accept() method to pass an IEmberVisitor implementation to /// examine the node.</param> protected virtual void OnNewContainer(EmberNode node) { }
protected void InsertChildNodeBase(EmberNode node) { base.InsertChildNode(node); }