ArtemisComm.SystemNode.GetNodes C# (CSharp) Method

GetNodes() public static method

public static GetNodes ( Stream stream, int index ) : ReadOnlyCollection
stream Stream
index int
return ReadOnlyCollection
        public static ReadOnlyCollection<SystemNode> GetNodes(Stream stream, int index)
        {
            List<SystemNode> retVal = new List<SystemNode>();
            byte endCheck = 0;
            do
            {
                SystemNode nd = new SystemNode(stream, index);
                index += nd.DataLength;
                retVal.Add(nd);
                if (index < stream.Length)
                {
                    stream.Position = index;
                    endCheck = Convert.ToByte(stream.ReadByte());
                }
            } while (endCheck != 255 && index < stream.Length);
            return new ReadOnlyCollection<SystemNode>(retVal);
        }

Usage Example

Example #1
0
        public EngGridUpdatePacket(byte[] byteArray)
        {
            if (_log.IsInfoEnabled)
            {
                _log.InfoFormat("{0}--bytes in: {1}", MethodBase.GetCurrentMethod().ToString(), Utility.BytesToDebugString(byteArray));
            }
            Systems = SystemNode.GetNodes(byteArray);
            int index = 0;

            foreach (SystemNode node in Systems)
            {
                index += node.DataLength;
            }

            DamageControlTeams = DamComStatus.GetDamComTeams(byteArray, ++index);

            if (_log.IsInfoEnabled)
            {
                _log.InfoFormat("{0}--Result bytes: {1}", MethodBase.GetCurrentMethod().ToString(), Utility.BytesToDebugString(this.GetBytes()));
            }
        }