Ejemplo n.º 1
0
        /// <summary>
        /// Serialize a RngParams class
        /// </summary>
        ///
        /// <param name="RngObj">A RngParams class</param>
        ///
        /// <returns>A stream containing the RngParams data</returns>
        public static Stream Serialize(RngParams RngObj)
        {
            MemoryStream stream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(stream);

            writer.Write(RngObj.Seed != null ? (short)RngObj.Seed.Length : (short)0);
            writer.Write(RngObj.Nonce != null ? (short)RngObj.Nonce.Length : (short)0);
            writer.Write(RngObj.Info != null ? (short)RngObj.Info.Length : (short)0);

            if (RngObj.Seed != null)
            {
                writer.Write(RngObj.Seed);
            }
            if (RngObj.Nonce != null)
            {
                writer.Write(RngObj.Nonce);
            }
            if (RngObj.Info != null)
            {
                writer.Write(RngObj.Info);
            }

            stream.Seek(0, SeekOrigin.Begin);

            return(stream);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Compare this RngParams instance with another
        /// </summary>
        ///
        /// <param name="Obj">RngParams to compare</param>
        ///
        /// <returns>Returns true if equal</returns>
        public bool Equals(RngParams Obj)
        {
            if (!Compare.IsEqual(Obj.Seed, m_Seed))
            {
                return(false);
            }
            if (!Compare.IsEqual(Obj.Nonce, m_Nonce))
            {
                return(false);
            }
            if (!Compare.IsEqual(Obj.Info, m_Info))
            {
                return(false);
            }

            return(true);
        }