Esempio n. 1
0
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return(false);
            }

            if (ReferenceEquals(this, obj))
            {
                return(true);
            }

            if (obj is LazyNumberValue lazyDouble)
            {
                return(Equals(lazyDouble));
            }

            if (obj is double dbl)
            {
                return(Math.Abs(this - dbl) < double.Epsilon);
            }

            if (obj is decimal dec)
            {
                return(((decimal)this).Equals(dec));
            }

            if (obj is LazyStringValue l &&
                l.Length == 3)           // checking for 3 as optimization
            {
                return(Inner.Equals(l)); // this is to match NaN
            }
            return(false);
        }
Esempio n. 2
0
        protected bool Equals(LazyDoubleValue other)
        {
            if (_val != null && other._val != null)
            {
                return(Math.Abs(_val.Value - other._val.Value) < double.Epsilon);
            }

            if (_decimalVal != null && other._decimalVal != null)
            {
                return(_decimalVal.Value.Equals(other._decimalVal.Value));
            }

            return(Inner.Equals(other.Inner));
        }