示例#1
0
        public ResultNodeState(IState parentState, IResultNodeBuilder resultNodeBuilder, IActiveState activeState,
                               Creator <IResultAttributeBuilder> createAttributeBuilder,
                               Creator <IAttributeState, IState, IResultAttributeBuilder> createAttributeState)

            : base(parentState, resultNodeBuilder, activeState, createAttributeBuilder, createAttributeState)
        {
        }
示例#2
0
        public void Parse <T>(IResultParser <T> parser, T reader) where T : IReader
        {
            long offset = reader.Position;

            IResultNodeBuilder resultNodeBuilder = _createResultNodeBuilder();
            IResultNodeState   resultState       = _createResultNodeReaderState(this, resultNodeBuilder);
            IState             previousState     = _activeState.ChangeState(resultState);

            try
            {
                parser.Parse(reader, resultState);
            }
            finally
            {
                _activeState.ChangeState(previousState);
            }

            if (Valid && (reader.Position > offset))
            {
                resultNodeBuilder.DataPacket = reader.GetDataPacket(offset, (reader.Position - offset));
                resultNodeBuilder.Metadata   = _resultMetadata;

                if (!resultState.Valid)
                {
                    resultNodeBuilder.Invalidate();
                }

                _resultNodeCallback.AddNode(_rootResultNode, resultNodeBuilder.Build(), resultState);
            }
        }