Beispiel #1
0
        /// <inheritdoc/>
        public override bool Equals(IRecordReader other)
        {
            if (other == null)
            {
                return(false);
            }

            // they need to be the same type
            if (other.GetType() != GetType())
            {
                return(false);
            }

            var o = (OneToOne <T>)other;

            if (o.Callback != Callback)
            {
                return(false);
            }

            // validate that the columns are the same object
            if (SplitColumns != o.SplitColumns)
            {
                // different objects, so we have to check the contents.
                // this is a performance hit, so you should pass in the same id mapping each time!
                var otherSplitColumns = o.SplitColumns;

                // check the count first as a short-circuit
                if (SplitColumns.Count != otherSplitColumns.Count)
                {
                    return(false);
                }

                // check the id mappings individually
                foreach (var pair in SplitColumns)
                {
                    string otherID;
                    if (!otherSplitColumns.TryGetValue(pair.Key, out otherID))
                    {
                        return(false);
                    }

                    if (pair.Value != otherID)
                    {
                        return(false);
                    }
                }

                return(false);
            }

            return(true);
        }