Exemple #1
0
        /// <summary>
        /// Determines whether the specified PropertyInstanceValueData is equal to the current PropertyInstanceValueData.
        /// </summary>
        /// <param name="that">The PropertyInstanceValueData to compare with the current object.</param>
        /// <returns>Returns true if the specified object has the same value type and same vale as the current PropertyInstanceValueData; otherwise false.</returns>
        public virtual bool Equals(PropertyInstanceValueData that)
        {
            // if that is null - not equal
            if (ReferenceEquals(that, null))
            {
                return(false);
            }

            // if that is has same reference to me - equal
            if (ReferenceEquals(this, that))
            {
                return(true);
            }

            // if that has a different value type than me - not equal
            if (ValueType != that.ValueType)
            {
                return(false);
            }

            // finally - if that has the same actual value as me - equal (otherwise, not equal)
            switch (ValueType)
            {
            case ValueTypeDefinitionData.Reference:
                return(ReferenceValue.Equals(that.ReferenceValue));

            case ValueTypeDefinitionData.DateTime:
                return(DateTimeValue.Equals(that.DateTimeValue));

            case ValueTypeDefinitionData.Bool:
                return(BoolValue == that.BoolValue);

            case ValueTypeDefinitionData.Float:
                return(FloatValue == that.FloatValue);

            case ValueTypeDefinitionData.Int:
                return(IntValue == that.IntValue);

            case ValueTypeDefinitionData.StringNonUnicode:
                return(StringNonUnicodeValue.Equals(that.StringNonUnicodeValue));

            default:
                return(false);
            }
        }
Exemple #2
0
 protected bool Equals(ClassWithAllTypes other)
 {
     return(CharValue == other.CharValue &&
            ByteValue == other.ByteValue &&
            SByteValue == other.SByteValue &&
            ShortValue == other.ShortValue &&
            UShortValue == other.UShortValue &&
            IntValue == other.IntValue &&
            UIntValue == other.UIntValue &&
            LongValue == other.LongValue &&
            ULongValue == other.ULongValue &&
            FloatValue.Equals(other.FloatValue) &&
            DoubleValue.Equals(other.DoubleValue) &&
            DecimalValue == other.DecimalValue &&
            DateTimeValue.Equals(other.DateTimeValue) &&
            GuidValue.Equals(other.GuidValue) &&
            StringValue.Equals(other.StringValue));
 }
Exemple #3
0
        public override bool Equals(object obj)
        {
            CDateTimeEx dte = (obj as CDateTimeEx);

            if (!(obj is DateTime) && (dte == null))
            {
                return(false);
            }
            if (obj == null)
            {
                return(false);
            }
            if (dte != null)
            {
                return(DateTimeValue.Equals(dte.DateTimeValue));
            }
            else
            {
                return(DateTimeValue.Equals(obj));
            }
        }