public override byte[] Serialize(bool partofsomethingelse) { int pos = 0; byte[] headerBytes = header.Serialize(); byte[] goalIDBytes = goal_id.Serialize(); byte[] goalBytes = goal.Serialize(); byte[] bytes = new byte[headerBytes.Length + goalBytes.Length + goalIDBytes.Length]; headerBytes.CopyTo(bytes, 0); pos = headerBytes.Length; goalIDBytes.CopyTo(bytes, pos); pos += goalIDBytes.Length; goalBytes.CopyTo(bytes, pos); return(bytes); }
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; IntPtr ptr; int x__size; //header if (header == null) { header = new Messages.std_msgs.Header(); } pieces.Add(header.Serialize(true)); //status scratch1 = new byte[Marshal.SizeOf(typeof(int))]; h = GCHandle.Alloc(scratch1, GCHandleType.Pinned); Marshal.StructureToPtr(status, h.AddrOfPinnedObject(), false); h.Free(); pieces.Add(scratch1); //details if (details == null) { details = ""; } scratch1 = Encoding.ASCII.GetBytes((string)details); 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); }
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; IntPtr ptr; int x__size; //header if (header == null) { header = new Messages.std_msgs.Header(); } pieces.Add(header.Serialize(true)); //system_status scratch1 = new byte[Marshal.SizeOf(typeof(int))]; h = GCHandle.Alloc(scratch1, GCHandleType.Pinned); Marshal.StructureToPtr(system_status, h.AddrOfPinnedObject(), false); h.Free(); pieces.Add(scratch1); //topics hasmetacomponents |= false; if (topics == null) { topics = new string[0]; } pieces.Add(BitConverter.GetBytes(topics.Length)); for (int i = 0; i < topics.Length; i++) { //topics[i] if (topics[i] == null) { topics[i] = ""; } scratch1 = Encoding.ASCII.GetBytes((string)topics[i]); 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); } //err_code hasmetacomponents |= false; if (err_code == null) { err_code = new int[0]; } pieces.Add(BitConverter.GetBytes(err_code.Length)); // Start Xamla //err_code x__size = Marshal.SizeOf(typeof(int)) * err_code.Length; scratch1 = new byte[x__size]; Buffer.BlockCopy(err_code, 0, scratch1, 0, x__size); pieces.Add(scratch1); // End Xamla //topic_msg hasmetacomponents |= false; if (topic_msg == null) { topic_msg = new string[0]; } pieces.Add(BitConverter.GetBytes(topic_msg.Length)); for (int i = 0; i < topic_msg.Length; i++) { //topic_msg[i] if (topic_msg[i] == null) { topic_msg[i] = ""; } scratch1 = Encoding.ASCII.GetBytes((string)topic_msg[i]); 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); }