Exemplo n.º 1
0
        public void MergeWith(object obj)
        {
            // Same as CommonTable.MergeWith

            if (!MergeHelper.IsMergeable(this, obj))
            {
                return;
            }

            CommonSortedTable <T> t = (CommonSortedTable <T>)obj;

            // Check values
            foreach (KeyValuePair <string, T> item in t.STable)
            {
                if (!_stable.ContainsKey(item.Key))
                {
                    Add(item.Value);
                }
                else
                {
                    T value = _stable[item.Key];
                    if (typeof(IMergeable).IsAssignableFrom(value.GetType()))
                    {
                        ((IMergeable)value).MergeWith(item.Value);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            CommonSortedTable <T> t = (CommonSortedTable <T>)obj;

            // Check size first
            int cnt = _stable.Count;

            if (cnt != t.Count)
            {
                return(false);
            }

            // Check keys and values. List is sorted
            for (int i = 0; i < cnt; i++)
            {
                T item2 = t[i];

                if ((item2 == null) || !_stable.Values[i].Equals(item2))
                {
                    return(false);
                }
            }

            // No differences found
            return(true);
        }