Beispiel #1
0
        public bool build(byte[] byteStream, ref Int32 offset)
        {
            ProtoCRT_t <UInt32> element_count = new ProtoCRT_t <UInt32>();

            if (!element_count.build(byteStream, ref offset))
            {
                return(false);
            }
            if (0 == element_count.value_)
            {
                value_ = null;
                return(true);
            }

            value_ = new T[element_count.value_];
            ProtoCRT_t <T> tmp = new ProtoCRT_t <T>();

            for (UInt32 i = 0; i < element_count.value_; ++i)
            {
                if (!tmp.build(byteStream, ref offset))
                {
                    return(false);
                }
                value_[i] = tmp.value_;
            }
            return(true);
        }
Beispiel #2
0
        public bool serialize(byte[] byteStream, ref Int32 offset)
        {
            byte[] r_byte = null;
            ProtoCRT_t <UInt32> element_count = new ProtoCRT_t <UInt32>(0);

            if (null == value_ || 0 == value_.Length)
            {
                element_count.value_ = 0;
            }
            else
            {
                r_byte = StringHelper.String2GB2312(value_);
                element_count.value_ = (UInt32)r_byte.Length;
            }
            if (!element_count.serialize(byteStream, ref offset))
            {
                return(false);
            }
            if (null == r_byte)
            {
                return(true);
            }
            if (offset + r_byte.Length > byteStream.Length)
            {
                return(false);
            }

            Buffer.BlockCopy(r_byte, 0, byteStream, offset, r_byte.Length);
            offset += r_byte.Length;
            return(true);
        }
Beispiel #3
0
        public bool serialize(byte[] byteStream, ref Int32 offset)
        {
            ProtoCRT_t <UInt32> element_count = new ProtoCRT_t <UInt32>();

            if (null == value_ || 0 == value_.Length)
            {
                element_count.value_ = 0;
            }
            else
            {
                element_count.value_ = (UInt32)value_.Length;
            }
            if (!element_count.serialize(byteStream, ref offset))
            {
                return(false);
            }
            if (null == value_ || 0 == value_.Length)
            {
                return(true);
            }
            ProtoCRT_t <T> tmp = new ProtoCRT_t <T>();

            foreach (var item in value_)
            {
                tmp.value_ = item;
                if (!tmp.serialize(byteStream, ref offset))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #4
0
        public int length()
        {
            int sum = 0;

            sum += ProtoCRT_t <UInt32> .type_length();

            foreach (var item in this)
            {
                sum += item.length();
            }
            return(sum);
        }
Beispiel #5
0
        public int length()
        {
            int sum = 0;

            sum += ProtoCRT_t <UInt32> .type_length();

            if (null != value_ && value_.Length != 0)
            {
                byte[] r_byte = StringHelper.String2GB2312(value_);
                sum += r_byte.Length;
            }
            return(sum);
        }
Beispiel #6
0
        public int length()
        {
            int sum = 0;

            sum += ProtoCRT_t <UInt32> .type_length();

            if (null == value_ || 0 == value_.Length)
            {
                return(sum);
            }
            sum += ProtoCRT_t <T> .type_length() * value_.Length;

            return(sum);
        }
Beispiel #7
0
        public bool serialize(byte[] byteStream, ref Int32 offset)
        {
            ProtoCRT_t <UInt32> element_count = new ProtoCRT_t <UInt32>((UInt32)base.Count);

            if (!element_count.serialize(byteStream, ref offset))
            {
                return(false);
            }
            foreach (var item in this)
            {
                if (!item.serialize(byteStream, ref offset))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #8
0
        public bool build(byte[] _byte_stream, ref Int32 _offset)
        {
            ProtoCRT_t <UInt32> element_count = new ProtoCRT_t <UInt32>();

            if (!element_count.build(_byte_stream, ref _offset))
            {
                return(false);
            }
            for (UInt32 i = 0; i < element_count.value_; ++i)
            {
                T item = new T();
                if (!item.build(_byte_stream, ref _offset))
                {
                    return(false);
                }
                else
                {
                    base.Add(item);
                }
            }
            return(true);
        }
Beispiel #9
0
        public bool build(byte[] byteStream, ref Int32 offset)
        {
            ProtoCRT_t <UInt32> element_count = new ProtoCRT_t <UInt32>();

            if (!element_count.build(byteStream, ref offset))
            {
                return(false);
            }
            if (0 == element_count.value_)
            {
                value_ = "";
                return(true);
            }
            else if (offset + element_count.value_ > byteStream.Length)
            {
                return(false);
            }

            byte[] b_data = new byte[element_count.value_];
            Buffer.BlockCopy(byteStream, offset, b_data, 0, (int)element_count.value_);
            offset += (int)element_count.value_;
            value_  = StringHelper.GB2312ToString(b_data);
            return(true);
        }