Esempio n. 1
0
        private int ReadByType(SocketDataHeadType pType, byte[] pBuffer, int pOffset)
        {
            int ret = -1;

            switch (pType)
            {
            case SocketDataHeadType.type_short:
                ret = BufferBase.SReadShort(pBuffer, pOffset);
                break;

            case SocketDataHeadType.type_ushort:
                ret = BufferBase.SReadUShort(pBuffer, pOffset);
                break;

            case SocketDataHeadType.type_int:
                ret = BufferBase.SReadInt(pBuffer, pOffset);
                break;

            default:
                DLog.LogErrorFormat("ReadByType -> Type error : {0}", pType);
                break;
            }

            return(ret);
        }
Esempio n. 2
0
        public SocketDataHeadType GetTypeAndSize(System.Type pType, out int pSize)
        {
            SocketDataHeadType ret = SocketDataHeadType.none;

            switch (pType.Name)
            {
            case "Int16":
                ret   = SocketDataHeadType.type_short;
                pSize = 2;
                break;

            case "UInt16":
                ret   = SocketDataHeadType.type_ushort;
                pSize = 2;
                break;

            case "Int32":
                ret   = SocketDataHeadType.type_int;
                pSize = 4;
                break;

            default:
                pSize = -1;
                DLog.LogErrorFormat("GetTypeAndSize -> Type error : {0}", pType.Name);
                break;
            }

            return(ret);
        }
Esempio n. 3
0
        public byte[] GetByte(SocketDataHeadType pType, int pSrc)
        {
            byte[] ret = null;
            switch (pType)
            {
            case SocketDataHeadType.type_short:
                ret = BufferBase.GetBuffer((short)pSrc);
                break;

            case SocketDataHeadType.type_ushort:
                ret = BufferBase.GetBuffer((ushort)pSrc);
                break;

            case SocketDataHeadType.type_int:
                ret = BufferBase.GetBuffer((int)pSrc);
                break;

            default:
                DLog.LogErrorFormat("SocketData GetByte -> Type error : {0}", pType);
                break;
            }

            return(ret);
        }