public void Write() { this.stream_0.Write(Class328.byte_0, 0, Class328.byte_0.Length); this.stream_0.Write(LittleEndianBitConverter.GetBytes(1), 0, 4); this.stream_0.WriteByte((byte)0); this.stream_0.Write(Class328.byte_1, 0, Class328.byte_1.Length); }
public void LittleEndianBitConverter_Double() { const int n = sizeof(Double); const Double pos = Math.PI; const Double zero = 0; const Double neg = -pos; var posRepr = GetCanonicalRepresentation(pos); var negRepr = GetCanonicalRepresentation(neg); // -------------------------------------------------------------- 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.ToDouble(buffer)); LittleEndianBitConverter.FillBytes(zero, buffer); Assert.IsTrue(buffer.SequenceEqual(new byte[n])); Assert.IsTrue(LittleEndianBitConverter.GetBytes(zero).SequenceEqual(buffer)); Assert.AreEqual(zero, LittleEndianBitConverter.ToDouble(buffer)); LittleEndianBitConverter.FillBytes(neg, buffer); Assert.IsTrue(buffer.SequenceEqual(negRepr)); Assert.IsTrue(LittleEndianBitConverter.GetBytes(neg).SequenceEqual(buffer)); Assert.AreEqual(neg, LittleEndianBitConverter.ToDouble(buffer)); }
public void LittleEndianBitConverter_Int32() { const int n = sizeof(Int32); const Int32 pos = 0x11223344; const Int32 zero = 0; const Int32 neg = -pos; var posRepr = new byte[] { 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.ToInt32(buffer)); LittleEndianBitConverter.FillBytes(zero, buffer); Assert.IsTrue(buffer.SequenceEqual(new byte[n])); Assert.IsTrue(LittleEndianBitConverter.GetBytes(zero).SequenceEqual(buffer)); Assert.AreEqual(zero, LittleEndianBitConverter.ToInt32(buffer)); LittleEndianBitConverter.FillBytes(neg, buffer); Assert.IsTrue(buffer.SequenceEqual(Neg(posRepr))); Assert.IsTrue(LittleEndianBitConverter.GetBytes(neg).SequenceEqual(buffer)); Assert.AreEqual(neg, LittleEndianBitConverter.ToInt32(buffer)); }
public void LittleEndianBitConverter_Decimal() { const int n = sizeof(Decimal); const Decimal pos = 3.1415926535897932384626433833m; const Decimal zero = 0; const Decimal neg = -pos; var posRepr = GetCanonicalRepresentation(pos); var negRepr = GetCanonicalRepresentation(neg); // -------------------------------------------------------------- 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.ToDecimal(buffer)); LittleEndianBitConverter.FillBytes(zero, buffer); Assert.IsTrue(buffer.SequenceEqual(new byte[n])); Assert.IsTrue(LittleEndianBitConverter.GetBytes(zero).SequenceEqual(buffer)); Assert.AreEqual(zero, LittleEndianBitConverter.ToDecimal(buffer)); LittleEndianBitConverter.FillBytes(neg, buffer); Assert.IsTrue(buffer.SequenceEqual(negRepr)); Assert.IsTrue(LittleEndianBitConverter.GetBytes(neg).SequenceEqual(buffer)); Assert.AreEqual(neg, LittleEndianBitConverter.ToDecimal(buffer)); }
public void Write(Stream stream) { stream.Write(LittleEndianBitConverter.GetBytes(this.ulong_0), 0, 8); stream.Write(LittleEndianBitConverter.GetBytes(this.ulong_1), 0, 8); stream.Write(LittleEndianBitConverter.GetBytes(this.ulong_2), 0, 8); stream.Write(LittleEndianBitConverter.GetBytes(this.ulong_3), 0, 8); stream.Write(LittleEndianBitConverter.GetBytes(this.ulong_4), 0, 8); }
public override void imethod_5(string value) { if (string.IsNullOrEmpty(value)) { this.imethod_13(LittleEndianBitConverter.GetBytes((ushort)0), 0, 2); } else { this.imethod_13(LittleEndianBitConverter.GetBytes((ushort)value.Length), 0, 2); byte[] bytes = Encoding.Unicode.GetBytes(value); this.imethod_13(bytes, 0, bytes.Length); } }
public void SendInitializationPackets() { AgarPacket init1 = new AgarPacket(); init1.OpCode = (byte)ClientPacketType.Init1; init1.Payload = bc.GetBytes(5U); pacman.SendPacket(init1); AgarPacket init2 = new AgarPacket(); init2.OpCode = (byte)ClientPacketType.Init2; init2.Payload = bc.GetBytes(pacman.AgarServerVersion); pacman.SendPacket(init2); AgarPacket conntoken = new AgarPacket(); conntoken.OpCode = (byte)ClientPacketType.ConnectionToken; conntoken.Payload = Encoding.UTF8.GetBytes(pacman.ConnectionToken); // Lets hope the encoding is right pacman.SendPacket(conntoken); }
public void LittleEndianBitConverter_Boolean() { var buffer = new byte[1]; LittleEndianBitConverter.FillBytes(true, buffer); Assert.AreEqual(1, buffer[0]); Assert.IsTrue(LittleEndianBitConverter.GetBytes(true).SequenceEqual(buffer)); Assert.AreEqual(true, LittleEndianBitConverter.ToBoolean(buffer)); LittleEndianBitConverter.FillBytes(false, buffer); Assert.AreEqual(0, buffer[0]); Assert.IsTrue(LittleEndianBitConverter.GetBytes(false).SequenceEqual(buffer)); Assert.AreEqual(false, LittleEndianBitConverter.ToBoolean(buffer)); }
/// <summary> /// Write value to stream. /// </summary> /// <param name="s">stream</param> /// <param name="value">value</param> static public void Write(Stream s, byte[] value) { if (value == null) { byte[] lenBuf = LittleEndianBitConverter.GetBytes((int)0);//data length } else { byte[] buf = value; byte[] lenBuf = LittleEndianBitConverter.GetBytes((int)buf.Length); s.Write(lenBuf, 0, lenBuf.Length); //data length s.Write(buf, 0, buf.Length); } }
public void imethod_16(double value) { if (value == 0.0) { this.imethod_15((byte)2); } else if (value == 1.0) { this.imethod_15((byte)1); } else { this.imethod_15((byte)0); this.imethod_12(LittleEndianBitConverter.GetBytes(value)); } }
private void method_12() { int sectionStartPosition1 = (int)Class653.smethod_0(this.int_0); int num1 = sectionStartPosition1 + (int)this.memoryStream_0.Length; int sectionStartPosition2 = num1 + (int)this.memoryStream_4.Length; int sectionStartPosition3 = sectionStartPosition2 + (int)this.memoryStream_1.Length; int sectionStartPosition4 = sectionStartPosition3 + (int)this.memoryStream_2.Length + (int)this.memoryStream_3.Length + (int)this.memoryStream_5.Length; int sectionStartPosition5 = sectionStartPosition4 + (int)this.memoryStream_6.Length + (int)this.memoryStream_7.Length; MemoryStream memoryStream = new MemoryStream(); Interface29 streamWriter = Class724.Create(this.dxfVersion_0, (Stream)memoryStream, Encodings.GetEncoding((int)this.dxfModel_0.Header.DrawingCodePage)); streamWriter.imethod_13(Encodings.Ascii.GetBytes(this.dxfModel_0.Header.AcadVersionString), 0, 6); Interface29 nterface29 = streamWriter; byte[] numArray = new byte[7]; numArray[5] = (byte)15; numArray[6] = (byte)1; byte[] bytes = numArray; nterface29.imethod_12(bytes); streamWriter.imethod_19(num1); streamWriter.imethod_11((byte)27); streamWriter.imethod_11((byte)25); int num2 = (int)Class952.smethod_1(this.dxfModel_0.Header.DrawingCodePage); streamWriter.imethod_13(LittleEndianBitConverter.GetBytes((short)num2), 0, 2); streamWriter.imethod_13(LittleEndianBitConverter.GetBytes(this.int_0), 0, 4); long position = this.stream_0.Position; this.method_13(streamWriter, (byte)0, sectionStartPosition2, (int)this.memoryStream_1.Length); this.method_13(streamWriter, (byte)1, sectionStartPosition3, (int)this.memoryStream_2.Length); this.method_13(streamWriter, (byte)2, sectionStartPosition4, (int)this.memoryStream_6.Length); this.method_13(streamWriter, (byte)3, 0, 0); this.method_13(streamWriter, (byte)4, sectionStartPosition5, (int)this.memoryStream_9.Length); this.method_13(streamWriter, (byte)5, sectionStartPosition1, (int)this.memoryStream_0.Length); streamWriter.Flush(); ushort num3 = Stream1.smethod_1((ushort)49345, memoryStream.GetBuffer(), 0L, memoryStream.Length); streamWriter.imethod_18((short)num3); streamWriter.imethod_13(Class800.byte_4, 0, Class800.byte_4.Length); this.stream_0.Write(memoryStream.GetBuffer(), 0, (int)memoryStream.Length); }
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_UInt16() { const int n = sizeof(UInt16); const UInt16 pos = 0x1122; const UInt16 zero = 0; var posRepr = new byte[] { 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.ToUInt16(buffer)); LittleEndianBitConverter.FillBytes(zero, buffer); Assert.IsTrue(buffer.SequenceEqual(new byte[n])); Assert.IsTrue(LittleEndianBitConverter.GetBytes(zero).SequenceEqual(buffer)); Assert.AreEqual(zero, LittleEndianBitConverter.ToUInt16(buffer)); }
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 void Main() { var message = Encoding.ASCII.GetBytes("message \"Render\""); var lenc = new LittleEndianBitConverter(); var bytes = new List <byte[]>(new[] { lenc.GetBytes(message.LongLength), message }); var msg = new byte[bytes.Sum(barray => barray.LongLength)]; int offset = 0; foreach (var bArray in bytes) { Buffer.BlockCopy(bArray, 0, msg, offset, bArray.Length); offset = bArray.Length; } Console.WriteLine(BitConverter.ToString(msg).Replace("-", ":")); }
public void imethod_17(double value, double defaultValue) { if (value == defaultValue) { this.imethod_15((byte)0); } else { byte[] bytes1 = LittleEndianBitConverter.GetBytes(value); byte[] bytes2 = LittleEndianBitConverter.GetBytes(defaultValue); int num = 0; for (int index = 7; index >= 0 && (int)bytes1[index] == (int)bytes2[index]; --index) { ++num; } if (num >= 4) { this.imethod_15((byte)1); this.imethod_13(bytes1, 0, 4); } else if (num >= 2) { this.imethod_15((byte)2); this.imethod_11(bytes1[4]); this.imethod_11(bytes1[5]); this.imethod_11(bytes1[0]); this.imethod_11(bytes1[1]); this.imethod_11(bytes1[2]); this.imethod_11(bytes1[3]); } else { this.imethod_15((byte)3); this.imethod_12(bytes1); } } }
public static void smethod_16(Stream stream, double value) { byte[] bytes = LittleEndianBitConverter.GetBytes(value); stream.Write(bytes, 0, 8); }
private static IEnumerable <double> Pack(GamFile file) { var stream = new MemoryStream(); // Write GAM header and file size. var header = AsciiEncoding.GetBytes("GAM\0"); stream.WriteAll(header); var size = file.Infile.Length; stream.WriteAll(LittleEndianBitConverter.GetBytes(size)); // Loop over file and compress it. var read = 0; var bitmask = new List <int>(); var bitmaskPosition = -1; while (read < size) { yield return((float)read / size * 100); if (bitmask.Count == 0) { // Create 2-byte placeholder for bitmask, remember its position. bitmaskPosition = (int)stream.Tell(); stream.WriteAll(0, 0); } // Find best position in buffer to copy from, if such position exists. var(bestPosition, bestLength) = Find(file.Infile, read); if (bestPosition != null) { // Position found: write position and length to output. var seek = (byte)(read - bestPosition.Value); stream.WriteAll(seek, bestLength); read += bestLength; bitmask.Add(1); } else { // Can't copy from buffer, copy one byte from input to output. stream.WriteAll(file.Infile[read]); read += 1; bitmask.Add(0); } if (bitmask.Count == 16 || read >= size) { // Bitmask is full: update placeholder for bitmask. bitmask.Reverse(); var bitmaskShort = (short)bitmask.Aggregate((b, acc) => acc * 2 + b); stream.Seek(bitmaskPosition, SeekOrigin.Begin); stream.WriteAll(LittleEndianBitConverter.GetBytes(bitmaskShort)); stream.Seek(0, SeekOrigin.End); bitmask.Clear(); } } file.Outfile = stream.ToArray(); stream.Close(); yield return(100.0); }
internal virtual void Read() { int num1 = (int)this.binaryReader_0.ReadUInt16(); int num2 = (int)this.binaryReader_0.ReadUInt16(); ushort num3 = this.binaryReader_0.ReadUInt16(); Class2.Struct0[] shapeInfoList = new Class2.Struct0[(int)num3]; for (int index1 = 0; index1 < (int)num3; ++index1) { ushort index2 = this.binaryReader_0.ReadUInt16(); ushort length = this.binaryReader_0.ReadUInt16(); shapeInfoList[index1] = new Class2.Struct0(index2, length); } if (num3 <= (ushort)0) { return; } int num4 = 0; if (shapeInfoList[0].ushort_0 == (ushort)0) { num4 = 1; this.shxFile_0.method_1(this.method_0()); byte[] numArray = this.binaryReader_0.ReadBytes(4); this.shxFile_0.method_2((int)numArray[0]); this.shxFile_0.method_3((int)numArray[1]); this.shxFile_0.method_4((int)numArray[2]); } int degree; int plusMinus; int diameter; this.vmethod_0(shapeInfoList, out degree, out plusMinus, out diameter); for (int index = num4; index < (int)num3; ++index) { long position = this.binaryReader_0.BaseStream.Position; string description = this.method_0(); long num5 = this.binaryReader_0.BaseStream.Position - position; byte[] geometry = this.binaryReader_0.ReadBytes((int)shapeInfoList[index].ushort_1 - (int)num5); int ushort0 = (int)shapeInfoList[index].ushort_0; char ch; if (ushort0 == degree) { ch = '°'; } else if (ushort0 == plusMinus) { ch = '±'; } else if (ushort0 == diameter) { ch = 'Ø'; } else if (ushort0 > (int)byte.MaxValue) { ch = char.MinValue; } else { ch = this.encoding_0.GetChars(LittleEndianBitConverter.GetBytes(shapeInfoList[index].ushort_0))[0]; if (this.charRemapDelegate_0 != null) { ch = this.charRemapDelegate_0(ch); } } this.shxFile_0.method_0(new ShxShape(this.shxFile_0, (ushort)ushort0, ch, description, geometry)); } }
public void GetBytes() { var sut = new LittleEndianBitConverter(); Check.That(new byte[] { 0 }).ContainsExactly(sut.GetBytes(false)); Check.That(new byte[] { 1 }).ContainsExactly(sut.GetBytes(true)); Check.That(new byte[] { 0, 0 }).ContainsExactly(sut.GetBytes((short)0)); Check.That(new byte[] { 1, 0 }).ContainsExactly(sut.GetBytes((short)1)); Check.That(new byte[] { 0, 1 }).ContainsExactly(sut.GetBytes((short)256)); Check.That(new byte[] { 255, 255 }).ContainsExactly(sut.GetBytes((short)-1)); Check.That(new byte[] { 0, 0 }).ContainsExactly(sut.GetBytes((ushort)0)); Check.That(new byte[] { 1, 0 }).ContainsExactly(sut.GetBytes((ushort)1)); Check.That(new byte[] { 0, 1 }).ContainsExactly(sut.GetBytes((ushort)256)); Check.That(new byte[] { 255, 255 }).ContainsExactly(sut.GetBytes(ushort.MaxValue)); Check.That(new byte[] { 0, 0, 0, 0 }).ContainsExactly(sut.GetBytes(0)); Check.That(new byte[] { 1, 0, 0, 0 }).ContainsExactly(sut.GetBytes(1)); Check.That(new byte[] { 0, 1, 0, 0 }).ContainsExactly(sut.GetBytes(256)); Check.That(new byte[] { 0, 0, 1, 0 }).ContainsExactly(sut.GetBytes(65536)); Check.That(new byte[] { 0, 0, 0, 1 }).ContainsExactly(sut.GetBytes(16777216)); Check.That(new byte[] { 255, 255, 255, 255 }).ContainsExactly(sut.GetBytes(-1)); Check.That(new byte[] { 0, 0, 0, 0 }).ContainsExactly(sut.GetBytes(0u)); Check.That(new byte[] { 1, 0, 0, 0 }).ContainsExactly(sut.GetBytes(1u)); Check.That(new byte[] { 0, 1, 0, 0 }).ContainsExactly(sut.GetBytes(256u)); Check.That(new byte[] { 0, 0, 1, 0 }).ContainsExactly(sut.GetBytes(65536u)); Check.That(new byte[] { 0, 0, 0, 1 }).ContainsExactly(sut.GetBytes(16777216u)); Check.That(new byte[] { 255, 255, 255, 255 }).ContainsExactly(sut.GetBytes(uint.MaxValue)); Check.That(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }).ContainsExactly(sut.GetBytes(0L)); Check.That(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 }).ContainsExactly(sut.GetBytes(1L)); Check.That(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0 }).ContainsExactly(sut.GetBytes(256L)); Check.That(new byte[] { 0, 0, 1, 0, 0, 0, 0, 0 }).ContainsExactly(sut.GetBytes(65536L)); Check.That(new byte[] { 0, 0, 0, 1, 0, 0, 0, 0 }).ContainsExactly(sut.GetBytes(16777216L)); Check.That(new byte[] { 0, 0, 0, 0, 1, 0, 0, 0 }).ContainsExactly(sut.GetBytes(4294967296L)); Check.That(new byte[] { 0, 0, 0, 0, 0, 1, 0, 0 }).ContainsExactly(sut.GetBytes(1099511627776L)); Check.That(new byte[] { 0, 0, 0, 0, 0, 0, 1, 0 }).ContainsExactly(sut.GetBytes(281474976710656L)); Check.That(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }).ContainsExactly(sut.GetBytes(72057594037927936L)); Check.That(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 }).ContainsExactly(sut.GetBytes(-1L)); Check.That(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }).ContainsExactly(sut.GetBytes(0UL)); Check.That(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 }).ContainsExactly(sut.GetBytes(1UL)); Check.That(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0 }).ContainsExactly(sut.GetBytes(256UL)); Check.That(new byte[] { 0, 0, 1, 0, 0, 0, 0, 0 }).ContainsExactly(sut.GetBytes(65536UL)); Check.That(new byte[] { 0, 0, 0, 1, 0, 0, 0, 0 }).ContainsExactly(sut.GetBytes(16777216UL)); Check.That(new byte[] { 0, 0, 0, 0, 1, 0, 0, 0 }).ContainsExactly(sut.GetBytes(4294967296UL)); Check.That(new byte[] { 0, 0, 0, 0, 0, 1, 0, 0 }).ContainsExactly(sut.GetBytes(1099511627776UL)); Check.That(new byte[] { 0, 0, 0, 0, 0, 0, 1, 0 }).ContainsExactly(sut.GetBytes(281474976710656UL)); Check.That(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }).ContainsExactly(sut.GetBytes(72057594037927936UL)); Check.That(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 }).ContainsExactly(sut.GetBytes(ulong.MaxValue)); }
private void InnerConnect(int millisecondsTimeout) { if (Closing) { throw new NTcpException("Can't operate SingleConnectionCable when it is closing.", ErrorCode.Closing); } if (TryToConnect) { throw new NTcpException("Try to connect by other tread now.", ErrorCode.TryToConenct); } try { try { if (!_SyncConnection.Connected) { TryToConnect = true; CableId = 0; _SyncConnection.Connect(millisecondsTimeout, true); ulong processAffinity = (ulong)System.Diagnostics.Process.GetCurrentProcess().ProcessorAffinity; byte[] ret = _SyncConnection.SyncSend(MessageFlag.Inner, (uint)InnerEvent.GetProcessorId, LittleEndianBitConverter.GetBytes(processAffinity)); int processorId = LittleEndianBitConverter.ToInt32(ret, 0); CableId = LittleEndianBitConverter.ToUInt16(ret, sizeof(int)); _SyncConnection.SetProcessorId(processorId); OnConnectedEvent(); } } catch (Exception e) { OnErrorEvent("InnerConnect", e); return; } if (Capacity == 1) { return; } while (true) { SingleConnection pendingConn; lock (_LockObj) { if (_PendingAsyncConnections.Count <= 0) { return; } pendingConn = _PendingAsyncConnections.Dequeue(); } try { TryToConnect = true; pendingConn.Connect(millisecondsTimeout); lock (_LockObj) { _WorkingAsyncConnections.AddLast(pendingConn); } } catch (Exception e) { _PendingAsyncConnections.Enqueue(pendingConn); OnErrorEvent("InnerConnect", e); return; } } } finally { TryToConnect = false; } }
public virtual void vmethod_5(short value) { this.stream_0.Write(LittleEndianBitConverter.GetBytes(value), 0, 2); }
internal static Class895 smethod_0(string fontFileName) { lock (Class810.dictionary_0) { Class895 class895; if (Class810.dictionary_0.TryGetValue(fontFileName, out class895)) { return(class895); } Struct9 struct9 = new Struct9(); Struct10 struct10 = new Struct10(); Struct11 struct11 = new Struct11(); Struct12 struct12 = new Struct12(); string path = !Path.IsPathRooted(fontFileName) ? (!(Path.GetFileName(fontFileName) == fontFileName) ? fontFileName : Environment.ExpandEnvironmentVariables(Path.Combine("%WINDIR%\\Fonts", fontFileName))) : fontFileName; if (!File.Exists(path)) { return((Class895)null); } FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); try { BinaryReader r = new BinaryReader((Stream)fs); byte[] source1 = Class810.smethod_2(r.ReadBytes(Marshal.SizeOf((object)struct9))); IntPtr num1 = Marshal.AllocHGlobal(source1.Length); Marshal.Copy(source1, 0, num1, source1.Length); Struct9 structure1 = (Struct9)Marshal.PtrToStructure(num1, typeof(Struct9)); Marshal.FreeHGlobal(num1); if (structure1.ushort_0 != (ushort)1 || structure1.ushort_1 != (ushort)0) { return((Class895)null); } bool flag = false; Struct10 tbName = new Struct10(); for (int index = 0; index < (int)structure1.ushort_2; ++index) { byte[] source2 = r.ReadBytes(Marshal.SizeOf((object)struct10)); IntPtr num2 = Marshal.AllocHGlobal(source2.Length); Marshal.Copy(source2, 0, num2, source2.Length); tbName = (Struct10)Marshal.PtrToStructure(num2, typeof(Struct10)); Marshal.FreeHGlobal(num2); string str = tbName.char_0.ToString() + tbName.char_1.ToString() + tbName.char_2.ToString() + tbName.char_3.ToString(); if (str != null && str.ToString() == "name") { flag = true; byte[] bytes1 = LittleEndianBitConverter.GetBytes(tbName.uint_2); byte[] bytes2 = LittleEndianBitConverter.GetBytes(tbName.uint_1); Array.Reverse((Array)bytes1); Array.Reverse((Array)bytes2); tbName.uint_2 = LittleEndianBitConverter.ToUInt32(bytes1); tbName.uint_1 = LittleEndianBitConverter.ToUInt32(bytes2); break; } } if (flag) { fs.Position = (long)tbName.uint_1; byte[] source2 = Class810.smethod_2(r.ReadBytes(Marshal.SizeOf((object)struct11))); IntPtr num2 = Marshal.AllocHGlobal(source2.Length); Marshal.Copy(source2, 0, num2, source2.Length); Struct11 structure2 = (Struct11)Marshal.PtrToStructure(num2, typeof(Struct11)); Marshal.FreeHGlobal(num2); class895 = new Class895(); for (int index = 0; index < (int)structure2.ushort_1; ++index) { byte[] source3 = Class810.smethod_2(r.ReadBytes(Marshal.SizeOf((object)struct12))); IntPtr num3 = Marshal.AllocHGlobal(source3.Length); Marshal.Copy(source3, 0, num3, source3.Length); Struct12 structure3 = (Struct12)Marshal.PtrToStructure(num3, typeof(Struct12)); Marshal.FreeHGlobal(num3); if (structure3.ushort_0 == (ushort)3 && structure3.ushort_2 == (ushort)1033) { switch (structure3.ushort_3) { case 1: class895.FamilyName = Class810.smethod_1(fs, r, ref tbName, ref structure2, ref structure3); continue; case 2: class895.SubFamilyName = Class810.smethod_1(fs, r, ref tbName, ref structure2, ref structure3); continue; case 3: class895.UniqueFontIdentifier = Class810.smethod_1(fs, r, ref tbName, ref structure2, ref structure3); continue; case 4: class895.FullFontName = Class810.smethod_1(fs, r, ref tbName, ref structure2, ref structure3); continue; default: continue; } } } } } finally { fs.Close(); } if (class895 != null) { class895.FullFilename = path; Class810.dictionary_0[fontFileName] = class895; } return(class895); } }
public virtual void vmethod_15(ulong value) { this.stream_0.Write(LittleEndianBitConverter.GetBytes(value), 0, 8); }
public void method_0(ushort value) { this.imethod_12(LittleEndianBitConverter.GetBytes(value)); }
public void imethod_20(double value) { this.imethod_12(LittleEndianBitConverter.GetBytes(value)); }
public void imethod_22(ulong value) { this.imethod_12(LittleEndianBitConverter.GetBytes(value)); }
public static void smethod_9(Stream stream, int value) { byte[] bytes = LittleEndianBitConverter.GetBytes(value); stream.Write(bytes, 0, 4); }
private static void smethod_4(Stream stream, char value) { WoutWareFont.Write(stream, LittleEndianBitConverter.GetBytes(value)); }
public unsafe double imethod_29(double defaultValue) { byte num1 = this.imethod_13(); switch (num1) { case 0: return(defaultValue); case 1: byte[] bytes1 = LittleEndianBitConverter.GetBytes(defaultValue); fixed(byte *numPtr1 = bytes1) { if (this.int_0 == 0) { this.method_6(); numPtr1[0] = this.byte_3; byte *numPtr2 = numPtr1 + 1; this.method_6(); * numPtr2 = this.byte_3; byte *numPtr3 = numPtr2 + 1; this.method_6(); * numPtr3 = this.byte_3; byte *numPtr4 = numPtr3 + 1; this.method_6(); *numPtr4 = this.byte_3; } else { numPtr1[0] = (byte)((uint)this.byte_3 << this.int_0); this.method_6(); byte *numPtr2 = numPtr1; int num2 = (int)(byte)((uint)*numPtr2 | (uint)(byte)((uint)this.byte_3 >> 8 - this.int_0)); * numPtr2 = (byte)num2; byte *numPtr3 = numPtr1 + 1; * numPtr3 = (byte)((uint)this.byte_3 << this.int_0); this.method_6(); byte *numPtr4 = numPtr3; int num3 = (int)(byte)((uint)*numPtr4 | (uint)(byte)((uint)this.byte_3 >> 8 - this.int_0)); * numPtr4 = (byte)num3; byte *numPtr5 = numPtr3 + 1; * numPtr5 = (byte)((uint)this.byte_3 << this.int_0); this.method_6(); byte *numPtr6 = numPtr5; int num4 = (int)(byte)((uint)*numPtr6 | (uint)(byte)((uint)this.byte_3 >> 8 - this.int_0)); * numPtr6 = (byte)num4; byte *numPtr7 = numPtr5 + 1; * numPtr7 = (byte)((uint)this.byte_3 << this.int_0); this.method_6(); byte *numPtr8 = numPtr7; int num5 = (int)(byte)((uint)*numPtr8 | (uint)(byte)((uint)this.byte_3 >> 8 - this.int_0)); * numPtr8 = (byte)num5; } } return(LittleEndianBitConverter.ToDouble(bytes1)); case 2: byte[] bytes2 = LittleEndianBitConverter.GetBytes(defaultValue); if (this.int_0 == 0) { this.method_6(); bytes2[4] = this.byte_3; this.method_6(); bytes2[5] = this.byte_3; this.method_6(); bytes2[0] = this.byte_3; this.method_6(); bytes2[1] = this.byte_3; this.method_6(); bytes2[2] = this.byte_3; this.method_6(); bytes2[3] = this.byte_3; } else { bytes2[4] = (byte)((uint)this.byte_3 << this.int_0); this.method_6(); bytes2[4] |= (byte)((uint)this.byte_3 >> 8 - this.int_0); bytes2[5] = (byte)((uint)this.byte_3 << this.int_0); this.method_6(); bytes2[5] |= (byte)((uint)this.byte_3 >> 8 - this.int_0); bytes2[0] = (byte)((uint)this.byte_3 << this.int_0); this.method_6(); bytes2[0] |= (byte)((uint)this.byte_3 >> 8 - this.int_0); bytes2[1] = (byte)((uint)this.byte_3 << this.int_0); this.method_6(); bytes2[1] |= (byte)((uint)this.byte_3 >> 8 - this.int_0); bytes2[2] = (byte)((uint)this.byte_3 << this.int_0); this.method_6(); bytes2[2] |= (byte)((uint)this.byte_3 >> 8 - this.int_0); bytes2[3] = (byte)((uint)this.byte_3 << this.int_0); this.method_6(); bytes2[3] |= (byte)((uint)this.byte_3 >> 8 - this.int_0); } return(LittleEndianBitConverter.ToDouble(bytes2)); case 3: return(this.imethod_42()); default: throw new DxfException("Illegal double type. " + num1.ToString()); } }