예제 #1
0
        public unsafe static Byte[] GetBytes(this IList objvalue)
        {
            int  l      = objvalue.Count;
            long offset = 0;

            byte[] b = new byte[512];
            fixed(byte *pb = &b[0])
            {
                for (int i = 0; i < l; i++)
                {
                    long   s = 0;
                    object o = objvalue[i];
                    if (o is string)
                    {
                        s = ((string)o).Length * sizeof(char);
                        if ((s + offset) > b.Length)
                            Array.Resize(ref b, (int)(s + offset));

                        fixed(char *c = (string)o)
                        Extractor.Cpblk(pb, (uint)offset, (byte *)c, 0, (uint)s);
                    }
                    else
                    {
                        s = o.GetSize();
                        Extractor.StructureToPointer(o, pb + offset);
                    }
                    offset += s;
                }
            }

            return(b);
        }
예제 #2
0
        public unsafe static Byte[] GetBytes(this String objvalue)
        {
            int l = objvalue.Length * sizeof(char);

            byte[] b = new byte[l];
            fixed(char *c = objvalue)
            fixed(byte *pb = b)
            {
                Extractor.Cpblk(pb, (byte *)c, (uint)l);
            }
            return(b);
        }