Пример #1
0
        //
        // RSL State machine implementation
        //

        public override bool LoadState(ManagedRSLCheckpointStream reader)
        {
            if (reader == null)
            {
                m_score = 0;
                return(false);
            }
            int totalRead = 0;
            int read      = 0;

            while (m_size > totalRead)
            {
                try
                {
                    read = reader.Read(m_state, totalRead, (int)m_size - totalRead);
                    Debug.Assert(read >= 0);
                }
                catch (IOException ioe)
                {
                    Console.WriteLine("Error: " + ioe);
                    return(false);
                }
                totalRead += read;
            }
            m_score = BitConverter.ToInt32(m_state, sizeof(Int32));
            return(true);
        }
Пример #2
0
        /// <summary>
        /// This method is called by the RSL engine at startup, read the last saved checkpoint
        /// </summary>
        /// <param name="reader"></param>
        public override bool LoadState(ManagedRSLCheckpointStream stream)
        {
            if (stream != null)
            {
                Byte[] buffer = new byte[4];

                while (stream.Read(buffer, 0, 4) != 0)
                {
                    _state.Add(System.BitConverter.ToUInt32(buffer, 0));
                }
            }
            return(true);
        }
Пример #3
0
        public override bool LoadState(ManagedRSLCheckpointStream stream)
        {
            Console.WriteLine(this.Self.MemberId + ".LoadState");
            if (stream != null)
            {
                int    length = (int)stream.Length;
                Byte[] buffer = new byte[length];

                if (stream.Read(buffer, 0, length) != (int)length)
                {
                    return(false);
                }

                this.InternalState = System.BitConverter.ToInt32(buffer, 0);

                return(true);
            }

            return(true);
        }