Пример #1
0
        /// <summary>
        /// Clone this object
        /// </summary>
        /// <returns>A deep Clone of this object</returns>
        public override object Clone()
        {
            var to = new Tuningoptions((CloneableDictionary <string, OptionTree>)base.Clone( ));

            // more objects to deep copy

#if DEBUG
            // check cloned item
            System.Diagnostics.Debug.Assert(CheckClone(to));
#endif
            return(to);
        }
Пример #2
0
        /// <summary>
        /// Check clone against This
        /// </summary>
        /// <param name="clone"></param>
        /// <returns>True if the clone is identical but not a shallow copy</returns>
        private bool CheckClone(Tuningoptions clone)
        {
            bool ret = true;

            // object vars first

            // check THIS Dictionary
            ret &= (this.Count == clone.Count);
            if (ret)
            {
                for (int i = 0; i < this.Count; i++)
                {
                    ret &= (this.ElementAt(i).Key == clone.ElementAt(i).Key);

                    ret &= (!object.ReferenceEquals(this.ElementAt(i).Value, clone.ElementAt(i).Value)); // shall not be the same object !!
                    ret &= (this.ElementAt(i).Value.CheckClone(clone.ElementAt(i).Value));               // sub check
                }
            }
            return(ret);
        }