示例#1
0
文件: Class444.cs 项目: 15831944/WW
        public unsafe int imethod_43()
        {
            int int32;

            fixed(byte *pointer = this.byte_5)
            {
                this.method_1(pointer);
                int32 = LittleEndianBitConverter.ToInt32(this.byte_5);
            }

            return(int32);
        }
示例#2
0
        /// <summary>
        /// Read data from stream
        /// </summary>
        /// <param name="s">stream</param>
        /// <returns>data of specified type</returns>
        public static byte[] ToData(Stream s)
        {
            byte[] lenBuf = new byte[sizeof(int)];

            s.Read(lenBuf, 0, lenBuf.Length);

            int len = LittleEndianBitConverter.ToInt32(lenBuf, 0);

            if (len == 0)
            {
                return(null);
            }
            else
            {
                byte[] buf = new byte[len];
                s.Read(buf, 0, len);
                return(buf);
            }
        }
示例#3
0
        /// <summary>
        /// Read data from stream
        /// </summary>
        /// <param name="s">stream</param>
        /// <returns>data of specified type</returns>
        public static string ToString(Stream s)
        {
            byte[] lenBuf = new byte[sizeof(int)];

            s.Read(lenBuf, 0, lenBuf.Length);

            int len = LittleEndianBitConverter.ToInt32(lenBuf, 0);

            if (len == 0)
            {
                return(null);
            }
            else
            {
                byte[] buf = new byte[len];
                s.Read(buf, 0, len);
                return(Encoding.UTF8.GetString(buf, 0, buf.Length));
            }
        }
示例#4
0
 private static int smethod_1(Stream stream, byte[] buffer)
 {
     stream.Read(buffer, 0, 4);
     return(LittleEndianBitConverter.ToInt32(buffer));
 }
示例#5
0
 public static int smethod_7(Stream stream)
 {
     byte[] numArray = new byte[4];
     stream.Read(numArray, 0, 4);
     return(LittleEndianBitConverter.ToInt32(numArray, 0));
 }
        public void ToXXX_ThrowsOnNull()
        {
            var sut = new LittleEndianBitConverter();

            Check.ThatCode(() => sut.ToInt32(null, 0)).Throws <ArgumentNullException>();
        }
示例#7
0
        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;
            }
        }
示例#8
0
 public virtual int vmethod_8()
 {
     byte[] numArray = new byte[4];
     this.stream_0.Read(numArray, 0, 4);
     return(LittleEndianBitConverter.ToInt32(numArray));
 }