Esempio n. 1
0
        protected override int CompareData(MemorySlice other, SliceComparer cmp, ushort size)
        {
            var prefixedSlice = other as PrefixedSlice;

            if (prefixedSlice != null)
            {
                return(SliceComparisonMethods.Compare(this, prefixedSlice, cmp, size));
            }

            var slice = other as Slice;

            if (slice != null)
            {
                return(SliceComparisonMethods.Compare(slice, this, cmp, size) * -1);
            }

            throw new NotSupportedException("Cannot compare because of unknown slice type: " + other.GetType());
        }
Esempio n. 2
0
        protected override int CompareData(MemorySlice other, SliceComparer cmp, ushort size)
        {
            var otherSlice = other as Slice;

            if (otherSlice != null)
            {
                if (Array != null)
                {
                    fixed(byte *a = Array)
                    {
                        if (otherSlice.Array != null)
                        {
                            fixed(byte *b = otherSlice.Array)
                            {
                                return(cmp(a, b, size));
                            }
                        }
                        return(cmp(a, otherSlice.Pointer, size));
                    }
                }

                if (otherSlice.Array != null)
                {
                    fixed(byte *b = otherSlice.Array)
                    {
                        return(cmp(Pointer, b, size));
                    }
                }

                return(cmp(Pointer, otherSlice.Pointer, size));
            }

            var prefixedSlice = other as PrefixedSlice;

            if (prefixedSlice != null)
            {
                return(SliceComparisonMethods.Compare(this, prefixedSlice, cmp, size));
            }

            throw new NotSupportedException("Cannot compare because of unknown slice type: " + other.GetType());
        }