Exemplo n.º 1
0
        public bool Equals(SmallString other)
        {
            if (_encodedBytes == null)
            {
                return(other._encodedBytes == null);
            }

            if (other._encodedBytes == null)
            {
                return(false);
            }

            if (_encodedBytes.Length != other._encodedBytes.Length)
            {
                return(false);
            }

            // If only one is a number, then they're not equal.
            if (((_flags ^ other._flags) & _SmallFlags.IsInt64) == _SmallFlags.IsInt64)
            {
                return(false);
            }

            if (_HasCachedHashCode && other._HasCachedHashCode)
            {
                if (_cachedHashCode != other._cachedHashCode)
                {
                    return(false);
                }
            }

            if (_IsInt64)
            {
                return(BitConverter.ToInt64(_encodedBytes, 0) == BitConverter.ToInt64(other._encodedBytes, 0));
            }

            // Note that this is doing a literal binary comparison of the two strings.
            // It's possible for two real strings to compare equally even though they
            // can be encoded in different ways with UTF8.
            return(Utility.MemCmp(_encodedBytes, other._encodedBytes, _encodedBytes.Length));
        }
Exemplo n.º 2
0
        public static bool AreImageSourcesEqual(ImageSource left, ImageSource right)
        {
            if (left == null)
            {
                return(right == null);
            }
            if (right == null)
            {
                return(false);
            }
            BitmapSource bitmapSource  = Utility.GenerateBitmapSource(left);
            BitmapSource bitmapSource1 = Utility.GenerateBitmapSource(right);

            byte[] bytesFromBitmapSource = Utility.GetBytesFromBitmapSource(bitmapSource);
            byte[] numArray = Utility.GetBytesFromBitmapSource(bitmapSource1);
            if ((int)bytesFromBitmapSource.Length != (int)numArray.Length)
            {
                return(false);
            }
            return(Utility.MemCmp(bytesFromBitmapSource, numArray, (int)bytesFromBitmapSource.Length));
        }
Exemplo n.º 3
0
        public bool Equals(SmallUri other)
        {
            if (_utf8String == null)
            {
                return(other._utf8String == null);
            }

            if (other._utf8String == null)
            {
                return(false);
            }

            if (_isHttp != other._isHttp)
            {
                return(false);
            }

            if (_utf8String.Length != other._utf8String.Length)
            {
                return(false);
            }

            return(Utility.MemCmp(_utf8String, other._utf8String, _utf8String.Length));
        }