Example #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            var b = obj as RecordContentsStream;

            if (b == null)
            {
                return(false);
            }

            // Check lengths first
            if (this.Length != b.Length)
            {
                return(false);
            }

            // Compare byte by byte.. kind of expensive
            //TODO: Do we really need such a strict equality criterium?
            byte[] bufForB = new byte[128];
            byte[] bufForA = new byte[128];
            this.Position = 0;
            b.Position    = 0;

            while (b.Read(bufForB, 0, bufForB.Length) > 0)
            {
                this.Read(bufForA, 0, bufForA.Length);

                if (!ByteUtils.AreEqual(bufForA, bufForB))
                {
                    return(false);
                }
            }

            return(true);
        }