Ejemplo n.º 1
0
        public override int GetHashCode()
        {
            int num;

            if (PropertyAsObject == null)
            {
                num = 0;
            }
            else if (PropertyType == EdmType.Binary)
            {
                num = 0;
                byte[] array = (byte[])PropertyAsObject;
                if (array.Length != 0)
                {
                    for (int i = 0; i < Math.Min(array.Length - 4, 1024); i += 4)
                    {
                        num ^= BitConverter.ToInt32(array, i);
                    }
                }
            }
            else
            {
                num = PropertyAsObject.GetHashCode();
            }
            return(num ^ PropertyType.GetHashCode() ^ IsNull.GetHashCode());
        }
Ejemplo n.º 2
0
        public bool Equals(EntityProperty other)
        {
            if (other == null)
            {
                return(false);
            }
            if (PropertyType != other.PropertyType)
            {
                return(false);
            }
            if (IsNull && other.IsNull)
            {
                return(true);
            }
            switch (PropertyType)
            {
            case EdmType.Binary:
                if (BinaryValue.Length == other.BinaryValue.Length)
                {
                    return(BinaryValue.SequenceEqual(other.BinaryValue));
                }
                return(false);

            case EdmType.Boolean:
                return(BooleanValue == other.BooleanValue);

            case EdmType.DateTime:
            {
                DateTime?dateTime  = DateTime;
                DateTime?dateTime2 = other.DateTime;
                if (dateTime.HasValue != dateTime2.HasValue)
                {
                    return(false);
                }
                if (!dateTime.HasValue)
                {
                    return(true);
                }
                return(dateTime.GetValueOrDefault() == dateTime2.GetValueOrDefault());
            }

            case EdmType.Double:
                return(DoubleValue == other.DoubleValue);

            case EdmType.Guid:
            {
                Guid?guidValue  = GuidValue;
                Guid?guidValue2 = other.GuidValue;
                if (guidValue.HasValue != guidValue2.HasValue)
                {
                    return(false);
                }
                if (!guidValue.HasValue)
                {
                    return(true);
                }
                return(guidValue.GetValueOrDefault() == guidValue2.GetValueOrDefault());
            }

            case EdmType.Int32:
                return(Int32Value == other.Int32Value);

            case EdmType.Int64:
                return(Int64Value == other.Int64Value);

            case EdmType.String:
                return(string.Equals(StringValue, other.StringValue, StringComparison.Ordinal));

            default:
                return(PropertyAsObject.Equals(other.PropertyAsObject));
            }
        }