示例#1
0
        public static VarTypeListModel DecodeByteArray(byte[] bytes)
        {
            VarTypeListModel Model = new VarTypeListModel();

            int offset = 0;

            while (offset < bytes.Length)
            {
                // read name string length
                byte len = ByteArrayHandler.GetBytesFromArray(bytes, offset, 1, false)[0];

                // get the VarType model
                int    arrayLen = len + 2;
                byte[] byteArr  = new byte[arrayLen];
                Buffer.BlockCopy(bytes, offset, byteArr, 0, arrayLen);
                VarTypeModel m = VarTypeModel.DecodeByteArray(byteArr);

                offset += arrayLen;

                // add model
                Model.VarTypes.Add(m);
            }

            return(Model);
        }
示例#2
0
        public static VarTypeModel DecodeByteArray(byte[] bytes)
        {
            int offset = 0;
            // read name string length
            byte len = ByteArrayHandler.GetBytesFromArray(bytes, offset, 1, false)[0];

            offset++;
            // get name string
            string name = Encoding.ASCII.GetString(ByteArrayHandler.GetBytesFromArray(bytes, offset, len, true));

            offset += len;
            // get var type
            byte varType = ByteArrayHandler.GetBytesFromArray(bytes, offset, 1, false)[0];

            offset++;
            // create model
            VarTypeModel m = new VarTypeModel {
                Name = name, VarType = (VarTypeEnum)varType
            };

            return(m);
        }