Beispiel #1
0
        /**
         * Writes the ptgs to the data buffer, starting at the specified offset.
         *
         * <br/>
         * The 2 byte encode Length field is <b>not</b> written by this method.
         * @return number of bytes written
         */
        public static int SerializePtgs(Ptg[] ptgs, byte[] array, int offset)
        {
            int size = ptgs.Length;

            LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(array, offset);

            ArrayList arrayPtgs = null;

            for (int k = 0; k < size; k++)
            {
                Ptg ptg = ptgs[k];

                ptg.Write(out1);
                if (ptg is ArrayPtg)
                {
                    if (arrayPtgs == null)
                    {
                        arrayPtgs = new ArrayList(5);
                    }
                    arrayPtgs.Add(ptg);
                }
            }
            if (arrayPtgs != null)
            {
                for (int i = 0; i < arrayPtgs.Count; i++)
                {
                    ArrayPtg p = (ArrayPtg)arrayPtgs[i];
                    p.WriteTokenValueBytes(out1);
                }
            }
            return(out1.WriteIndex - offset);;
        }
Beispiel #2
0
        /**
         * Writes the ptgs to the data buffer, starting at the specified offset.
         *
         * <br/>
         * The 2 byte encode Length field is <b>not</b> written by this method.
         * @return number of bytes written
         */
        public static int SerializePtgs(Ptg[] ptgs, byte[] array, int offset)
        {
            LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(array, offset);

            List <Ptg> arrayPtgs = null;

            foreach (Ptg ptg in ptgs)
            {
                ptg.Write(out1);
                if (ptg is ArrayPtg)
                {
                    if (arrayPtgs == null)
                    {
                        arrayPtgs = new List <Ptg>(5);
                    }
                    arrayPtgs.Add(ptg);
                }
            }
            if (arrayPtgs != null)
            {
                foreach (Ptg arrayPtg in arrayPtgs)
                {
                    ArrayPtg p = (ArrayPtg)arrayPtg;
                    p.WriteTokenValueBytes(out1);
                }
            }
            return(out1.WriteIndex - offset);;
        }