public void ToXXX() { var sut = new LittleEndianBitConverter(); var data = new byte[] { 0x03, 0, 0, 0, 0, 0, 0, 0 }; Check.That(sut.ToBoolean(data, 0)).IsTrue(); Check.That(sut.ToBoolean(data, 7)).IsFalse(); Check.That(sut.ToChar(data, 0)).IsEqualTo('\u0003'); Check.That(sut.ToChar(data, 6)).IsEqualTo('\0'); Check.That(sut.ToInt16(data, 0)).IsEqualTo(3); Check.That(sut.ToInt16(data, 6)).IsEqualTo(0); Check.That(sut.ToUInt16(data, 0)).IsEqualTo(3u); Check.That(sut.ToUInt16(data, 6)).IsEqualTo(0u); Check.That(sut.ToInt32(data, 0)).IsEqualTo(3); Check.That(sut.ToInt32(data, 4)).IsEqualTo(0); Check.That(sut.ToUInt32(data, 0)).IsEqualTo(3u); Check.That(sut.ToUInt32(data, 4)).IsEqualTo(0u); Check.That(sut.ToInt64(data, 0)).IsEqualTo(3L); Check.That(sut.ToUInt64(data, 0)).IsEqualTo(3UL); data = new byte[] { 0, 0, 0, 0, 0, 0, 0x20, 0x41 }; Check.That(sut.ToSingle(data, 0)).IsEqualTo(0.0f); Check.That(sut.ToSingle(data, 4)).IsEqualTo(10.0f); data = new byte[] { 0, 0, 0, 0, 0, 0, 0x24, 0x40 }; Check.That(sut.ToDouble(data, 0)).IsEqualTo(10.0); }
public ulong DecodeUint64(byte[] bytes, Iterator it) { ulong value = bitConverter.ToUInt64(bytes, it.Offset); it.Offset += 8; return(value); }
public Class995() { Random random = new Random(); byte[] numArray = new byte[8]; random.NextBytes(numArray); this.method_0(LittleEndianBitConverter.ToUInt64(numArray)); }
public unsafe ulong imethod_46() { ulong uint64; fixed(byte *pointer = this.byte_6) { this.method_2(pointer); uint64 = LittleEndianBitConverter.ToUInt64(this.byte_6); } return(uint64); }
private unsafe ulong method_3(int count) { if (this.stream_0.Read(this.byte_7, 0, count) < count) { throw new EndOfStreamException(); fixed(byte *numPtr1 = this.byte_6) { if (this.int_0 == 0) { byte *numPtr2 = numPtr1 + count - 1; fixed(byte *numPtr3 = this.byte_7) { byte *numPtr4 = numPtr3; for (int index = 0; index < count; ++index) { *numPtr2-- = *numPtr4++; } } } else { int num1 = 8 - this.int_0; byte *numPtr2 = numPtr1 + count - 1; fixed(byte *numPtr3 = this.byte_7) { byte *numPtr4 = numPtr3; for (int index = 0; index < count; ++index) { byte num2 = (byte)((uint)this.byte_3 << this.int_0); this.byte_3 = *numPtr4++; byte num3 = (byte)((uint)num2 | (uint)(byte)((uint)this.byte_3 >> num1)); * numPtr2-- = num3; } } } byte *numPtr5 = numPtr1 + count; for (int index = count; index < 8; ++index) { *numPtr5++ = (byte)0; } } return(LittleEndianBitConverter.ToUInt64(this.byte_6)); }
public Class921(Stream stream, DxfModel model) { if (!stream.CanSeek || !stream.CanWrite) { throw new ArgumentException("Stream must allow writing and seeking."); } this.dxfModel_0 = model; this.stream_0 = stream; this.dxfVersion_0 = model.Header.AcadVersion; this.encoding_0 = Encodings.GetEncoding((int)model.Header.DrawingCodePage); Random random = new Random(); byte[] numArray = new byte[8]; random.NextBytes(numArray); this.class995_0.method_0(LittleEndianBitConverter.ToUInt64(numArray)); this.uint_0 = 0U; this.class954_0.RandomSeed = this.class995_0.Seed; this.class954_0.CrcSeed = (ulong)this.uint_0; this.class954_0.PagesMapCrcSeed = (ulong)this.uint_0; this.class954_0.SectionsMapCrcSeed = (ulong)this.uint_0; }
private void ProcInnerMessage(Event.ReceiveEventArgs message) { try { switch ((InnerEvent)message.Event) { case InnerEvent.GetProcessorId: { //Get processorid and cableid //Only syncronize connection of single connection cable will //Send this event to server to alloc //Processor mask from client ulong mask = LittleEndianBitConverter.ToUInt64(message.Data, 0); //Get Processor id int pId = _AllocClientProcessor.GetProcessorId(((IPEndPoint)message.RemoteIPEndPoint).Address, mask, message.SCBID); //Get cable id SCB scb = GetSCB((IPEndPoint)message.RemoteIPEndPoint); UInt16 cableId = _CableIdAllocator.Alloc(scb.RemoteIPEndPoint); scb.CableId = cableId; message.ReturnData = new byte[sizeof(int) + sizeof(UInt16)]; Array.Copy(LittleEndianBitConverter.GetBytes(pId), 0, message.ReturnData, 0, sizeof(int)); Array.Copy(LittleEndianBitConverter.GetBytes(cableId), 0, message.ReturnData, sizeof(int), sizeof(UInt16)); } break; } } catch (Exception e) { OnErrorEvent("ProcInnerMessage", e); } }
public void LittleEndianBitConverter_UInt64() { const int n = sizeof(UInt64); const UInt64 pos = 0x1122334455667788; const UInt64 zero = 0; var posRepr = new byte[] { 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11 }; // -------------------------------------------------------------- var buffer = new byte[n]; LittleEndianBitConverter.FillBytes(pos, buffer); Assert.IsTrue(buffer.SequenceEqual(posRepr)); Assert.IsTrue(LittleEndianBitConverter.GetBytes(pos).SequenceEqual(buffer)); Assert.AreEqual(pos, LittleEndianBitConverter.ToUInt64(buffer)); LittleEndianBitConverter.FillBytes(zero, buffer); Assert.IsTrue(buffer.SequenceEqual(new byte[n])); Assert.IsTrue(LittleEndianBitConverter.GetBytes(zero).SequenceEqual(buffer)); Assert.AreEqual(zero, LittleEndianBitConverter.ToUInt64(buffer)); }
public static ulong smethod_14(Stream stream) { byte[] numArray = new byte[8]; stream.Read(numArray, 0, 8); return(LittleEndianBitConverter.ToUInt64(numArray, 0)); }
public virtual ulong vmethod_14() { byte[] numArray = new byte[8]; this.stream_0.Read(numArray, 0, 8); return(LittleEndianBitConverter.ToUInt64(numArray)); }