public override byte[] Serialize(bool partofsomethingelse)
        {
            int  currentIndex = 0, length = 0;
            bool hasmetacomponents = false;

            byte[]        thischunk, scratch1, scratch2;
            List <byte[]> pieces = new List <byte[]>();
            GCHandle      h;

            //link_name
            if (link_name == null)
            {
                link_name = "";
            }
            scratch1  = Encoding.ASCII.GetBytes((string)link_name);
            thischunk = new byte[scratch1.Length + 4];
            scratch2  = BitConverter.GetBytes(scratch1.Length);
            Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length);
            Array.Copy(scratch2, thischunk, 4);
            pieces.Add(thischunk);
            //pose
            if (pose == null)
            {
                pose = new Pose();
            }
            pieces.Add(pose.Serialize(true));
            //twist
            if (twist == null)
            {
                twist = new Twist();
            }
            pieces.Add(twist.Serialize(true));
            //reference_frame
            if (reference_frame == null)
            {
                reference_frame = "";
            }
            scratch1  = Encoding.ASCII.GetBytes((string)reference_frame);
            thischunk = new byte[scratch1.Length + 4];
            scratch2  = BitConverter.GetBytes(scratch1.Length);
            Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length);
            Array.Copy(scratch2, thischunk, 4);
            pieces.Add(thischunk);
            //combine every array in pieces into one array and return it
            int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length);
            int __a_b__e = 0;

            byte[] __a_b__d = new byte[__a_b__f];
            foreach (var __p__ in pieces)
            {
                Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length);
                __a_b__e += __p__.Length;
            }
            return(__a_b__d);
        }
示例#2
0
        public override byte[] Serialize(bool partofsomethingelse)
        {
            int  currentIndex = 0, length = 0;
            bool hasmetacomponents = false;

            byte[]        thischunk, scratch1, scratch2;
            List <byte[]> pieces = new List <byte[]>();
            GCHandle      h;

            //header
            if (header == null)
            {
                header = new Header();
            }
            pieces.Add(header.Serialize(true));
            //pose
            if (pose == null)
            {
                pose = new Pose();
            }
            pieces.Add(pose.Serialize(true));
            //twist
            if (twist == null)
            {
                twist = new Twist();
            }
            pieces.Add(twist.Serialize(true));
            //wrench
            if (wrench == null)
            {
                wrench = new Wrench();
            }
            pieces.Add(wrench.Serialize(true));
            //combine every array in pieces into one array and return it
            int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length);
            int __a_b__e = 0;

            byte[] __a_b__d = new byte[__a_b__f];
            foreach (var __p__ in pieces)
            {
                Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length);
                __a_b__e += __p__.Length;
            }
            return(__a_b__d);
        }