Example #1
0
        /// <summary>
        /// Determines whether two UKPerm instances are equal.
        /// </summary>
        /// <param name="obj">The UKPerm to compare with the
        /// current UKPerm.</param>
        /// <returns>true if the specified UKPerm is equal to the current
        /// UKPerm; otherwise, false.</returns>
        public override bool Equals(object obj)
        {
            UKPerm perm = obj as UKPerm;

            if (perm == null)
            {
                return(false);
            }
            else
            {
                return(Equals(perm));
            }
        }
Example #2
0
        /// <summary>
        /// Parses the response received from the server.
        /// </summary>
        protected override void UnpackResponse()
        {
            // Clear the perms.
            m_perms.Clear();

            base.UnpackResponse();

            // Create the streams we will be reading from.
            MemoryStream responseStream = new MemoryStream(m_responsePayload);
            BinaryReader responseReader = new BinaryReader(responseStream, Encoding.Unicode);

            // Check the response length.
            if (responseStream.Length < MinResponseMessageLength)
            {
                throw new MessageWrongSizeException(m_strMessageName);
            }

            // Try to unpack the data.
            try
            {
                // Seek past return code.
                responseReader.BaseStream.Seek(sizeof(int), SeekOrigin.Begin);

                // Count of TDMs.
                ushort tdmCount = responseReader.ReadUInt16();

                for (ushort x = 0; x < tdmCount; x++)
                {
                    UKPerm perm = new UKPerm();

                    // TDM
                    perm.TDM = responseReader.ReadInt16();

                    // Series
                    perm.Series = responseReader.ReadInt16();

                    // Serial Start
                    perm.SerialStart = responseReader.ReadInt32();

                    // Serial End
                    perm.SerialEnd = responseReader.ReadInt32();

                    // Perm Start
                    perm.Start = responseReader.ReadInt32();

                    // Page Step
                    perm.PageStep = responseReader.ReadInt32();

                    // Game Type
                    perm.GameType = (GameType)responseReader.ReadInt32();

                    m_perms.Add(perm);
                }
            }
            catch (EndOfStreamException e)
            {
                throw new MessageWrongSizeException(m_strMessageName, e);
            }
            catch (Exception e)
            {
                throw new ServerException(m_strMessageName, e);
            }

            // Close the streams.
            responseReader.Close();
        }
Example #3
0
 /// <summary>
 /// Determines whether two UKPerm instances are equal.
 /// </summary>
 /// <param name="other">The UKPerm to compare with the
 /// current UKPerm.</param>
 /// <returns>true if the specified UKPerm is equal to the current
 /// UKPerm; otherwise, false.</returns>
 public bool Equals(UKPerm other)
 {
     return(base.Equals(other) && m_tdm == other.m_tdm && m_series == other.m_series);
 }