Ejemplo n.º 1
0
        void WriteStreamLong(this Stream stream, int offset, long value, bool little)
        {
#if SAFE_CAST
            byte[] intBytes = new byte[8];

            fixed(byte *bs = intBytes)
            {
                long *c = (long *)bs;

                *c = value;
                if (BitConverter.IsLittleEndian != little)
                {
                    Reverse8(c);
                }
            }

            stream.Position = offset;
            stream.Write(intBytes, 0, intBytes.Length);
#else
            if (BitConverter.IsLittleEndian == little)
            {
                LongField fs = new LongField(value);
                fs.Fill(stream, offset);
            }
            else
            {
                RLongField fs = new RLongField(value);
                fs.Fill(stream, offset);
            }
#endif
        }
Ejemplo n.º 2
0
        void WriteLong(this byte[] arr, int offset, long value, bool little)
        {
#if SAFE_CAST
            fixed(byte *bs = arr)
            {
                long *target = (long *)(bs + offset);

                (*target) = value;
            }

            if (BitConverter.IsLittleEndian != little)
            {
                Reverse(arr, offset, 8);
            }
#else
            if (BitConverter.IsLittleEndian == little)
            {
                LongField fs = new LongField(value);
                fs.Fill(arr, offset);
            }
            else
            {
                RLongField fs = new RLongField(value);
                fs.Fill(arr, offset);
            }
#endif
        }