Ejemplo n.º 1
0
        /// <summary>
        /// Parses the streams records.
        /// </summary>
        public virtual void Parse()
        {
            while (Header.Stream.BeginRecord())
            {
                Opcodes op = Header.Stream.Opcode;

                if (GlobalHandler.Handles(op))                 // Check global handler
                {
                    if (!GlobalHandler.Handle(op))
                    {
                        break;
                    }
                }
                else if (ActiveHandler.Handles(op))                 // Try the active handler
                {
                    if (!ActiveHandler.Handle(op))
                    {
                        break;
                    }
                }
                else
                {
                    if (ActiveHandler.ThrowBackUnhandled || ActiveHandler.ThrowBacks.Contains(op))                     // Do we throw back the record to be handled by the parent?
                    {
                        //Log.Write( string.Format( "{0} throwing back - {1}", GetType().Name, op ) );
                        // Mark the record to be repeated by our parent.
                        Header.Stream.Repeat = true;
                        break;
                    }
                    else
                    {
                        // Just ignore the record.
                        Log.Write(string.Format("{0} not handled record - {1}", GetType().Name, op));
                    }
                }
            }
        }