Example #1
0
        public void Init(MarkupFrame parent, MarkupFrameType type, MarkupNode node)
        {
            if (parent == null)
            {
                Depth = 0;
            }
            else
            {
                ParentFrame = parent;
                Depth = parent.Depth + 1;
            }

            FrameType = type;
            Node = node;

            isInited = true;
        }
        /// <summary>
        /// Adds another node to be returned to consumer after current item.
        /// </summary>
        /// <param name="node"></param>
        protected void YieldReturnAfterCurrentNode(MarkupNode node)
        {
            if (yeildReturnBuffer == null)
                yeildReturnBuffer = new Queue<MarkupNode>();

            yeildReturnBuffer.Enqueue(node);
        }
 protected virtual MarkupNode VisitValueNode(MarkupNode node)
 {
     return node;
 }
 protected virtual MarkupNode VisitNode(MarkupNode node)
 {
     switch (node.NodeType)
     {
         case MarkupNodeType.Value:
             return VisitValueNode(node);
         case MarkupNodeType.BeginObject:
             return VisitBeginObjectNode(node);
         case MarkupNodeType.EndObject:
             return VisitEndObjectNode(node);
         case MarkupNodeType.BeginMember:
             return VisitBeginMemberNode(node);
         case MarkupNodeType.EndMember:
             return VisitEndMemberNode(node);
         case MarkupNodeType.NamespaceDeclaration:
             return VisitNamespaceDeclarationNode(node);
         case MarkupNodeType.EndOfDocument:
             return VisitEndOfDocumentNode(node);
         default:
             return VisitDefault(node);
     }
 }
 protected virtual MarkupNode VisitNamespaceDeclarationNode(MarkupNode node)
 {
     return node;
 }
 protected virtual MarkupNode VisitEndOfDocumentNode(MarkupNode node)
 {
     return node;
 }
 protected virtual MarkupNode VisitEndObjectNode(MarkupNode node)
 {
     return node;
 }
 protected virtual MarkupNode VisitEndMemberNode(MarkupNode node)
 {
     return node;
 }
 protected virtual MarkupNode VisitDefault(MarkupNode node)
 {
     return node;
 }