コード例 #1
0
        public override bool Equals(ChoDisposableObject obj)
        {
            if (Object.ReferenceEquals(obj, null))
            {
                return(false);
            }
            if (!(obj is ChoNameValueSection))
            {
                return(false);
            }

            ChoNameValueSection newSection = obj as ChoNameValueSection;

            if (this.Count == 0 && newSection.Count == 0)
            {
                return(true);
            }

            if (this.Count != newSection.Count)
            {
                return(false);
            }

            if (Object.ReferenceEquals(Collection, newSection.Collection))
            {
                return(true);
            }
            if (Object.ReferenceEquals(Collection, null))
            {
                return(false);
            }
            if (Object.ReferenceEquals(newSection.Collection, null))
            {
                return(false);
            }

            //Is all keys are same
            var diff = Collection.AllKeys.Except(newSection.Collection.AllKeys);

            if (diff.Count() != 0)
            {
                return(false);
            }

            //Check the values are equal
            foreach (string key in Collection.AllKeys)
            {
                if (!ChoObject.Equals(this[key], newSection[key]))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #2
0
        public override bool Equals(ChoDisposableObject obj)
        {
            if (Object.ReferenceEquals(obj, null))
            {
                return(false);
            }
            if (!(obj is ChoDictionarySection))
            {
                return(false);
            }

            ChoDictionarySection newSection = (ChoDictionarySection)obj;

            if (this.Count == 0 && newSection.Count == 0)
            {
                return(true);
            }

            if (this.Count != newSection.Count)
            {
                return(false);
            }

            if (Object.ReferenceEquals(Collection, newSection.Collection))
            {
                return(true);
            }
            if (Object.ReferenceEquals(Collection, null))
            {
                return(false);
            }
            if (Object.ReferenceEquals(newSection.Collection, null))
            {
                return(false);
            }

            foreach (DictionaryEntry keyValue in Collection)
            {
                if (!newSection.Collection.Contains(keyValue.Key))
                {
                    return(false);
                }

                if (!Object.Equals(keyValue.Value, newSection.Collection[keyValue.Key]))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #3
0
        public override bool Equals(ChoDisposableObject other)
        {
            ChoXmlSerializerSection other1 = other as ChoXmlSerializerSection;

            return(other1 == null ? false : _payload == other1._payload);
        }