Пример #1
0
        /// <summary>
        /// Serializes a SystemInformation object.
        /// </summary>
        /// <param name="info">the SystemInformation object</param>
        /// <returns>a serialized representation of the info object</returns>
        public static byte[] Serialize(SystemInformation info)
        {
            MemoryStream memStream = new MemoryStream();
            BinaryFormatter bFormatter = new BinaryFormatter();

            bFormatter.Serialize(memStream, info);

            return memStream.ToArray();
        }
Пример #2
0
        /// <summary>
        /// Generates a system information objet from the given packet.
        /// </summary>
        /// <param name="inPacket">contains the system information in a raw, serialized format</param>
        public static SystemInformation ReadFromPacket(PacketIn inPacket)
        {
            SystemInformation info = new SystemInformation();
        	inPacket.SkipBytes(1);	// 0

            try
            {
                info.Version = new ClientVersion(inPacket.ReadBytes(5));
                info.Architecture = inPacket.ReadReversedString();
                info.OS = inPacket.ReadReversedString();
                info.Locale = inPacket.ReadReversedPascalString(4);
                info.TimeZone = BitConverter.ToUInt32(inPacket.ReadBytes(4), 0);
                info.IPAddress = new XmlIPAddress(inPacket.ReadBytes(4));
            }
            catch
            {
            }

            return info;
        }