Ejemplo n.º 1
0
        protected bool Equals(BlittableJsonReaderObject other)
        {
            if (_propCount != other._propCount)
            {
                return(false);
            }

            foreach (var propertyName in GetPropertyNames())
            {
                object result;
                if (other.TryGetMember(propertyName, out result) == false)
                {
                    return(false);
                }

                var current = this[propertyName];

                if (current == null && result == null)
                {
                    continue;
                }

                if ((current?.Equals(result) ?? false) == false)
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        private static bool TryGetNullableTimeSpan(BlittableJsonReaderObject json, string propertyName, out TimeSpan?timeSpan)
        {
            if (json.TryGetMember(propertyName, out var value) == false || value == null)
            {
                timeSpan = null;
                return(false);
            }

            if (value is LazyStringValue || value is LazyCompressedStringValue || value is string)
            {
                BlittableJsonReaderObject.ConvertType(value, out timeSpan);
                return(true);
            }

            if (value is long l)
            {
                timeSpan = TimeSpan.FromMilliseconds(l);
                return(true);
            }

            if (value is LazyNumberValue lnv)
            {
                timeSpan = TimeSpan.FromMilliseconds(lnv);
                return(true);
            }

            throw new FormatException($"Could not convert {value.GetType().Name} ('{value}') to {typeof(TimeSpan).Name}");
        }