public override void Deserialize(byte[] serializedMessage, ref int currentIndex) { int arraylength = -1; bool hasmetacomponents = false; byte[] thischunk, scratch1, scratch2; object __thing; int piecesize = 0; IntPtr h; //path path = new Messages.xamlamoveit_msgs.CartesianPath(serializedMessage, ref currentIndex); //transient transient = serializedMessage[currentIndex++] == 1; //element_path element_path = ""; piecesize = BitConverter.ToInt32(serializedMessage, currentIndex); currentIndex += 4; element_path = Encoding.ASCII.GetString(serializedMessage, currentIndex, piecesize); currentIndex += piecesize; //display_name display_name = ""; piecesize = BitConverter.ToInt32(serializedMessage, currentIndex); currentIndex += 4; display_name = Encoding.ASCII.GetString(serializedMessage, currentIndex, piecesize); currentIndex += piecesize; }
public override void Randomize() { int arraylength = -1; Random rand = new Random(); int strlength; byte[] strbuf, myByte; //path path = new Messages.xamlamoveit_msgs.CartesianPath(); path.Randomize(); //success success = rand.Next(2) == 1; //error strlength = rand.Next(100) + 1; strbuf = new byte[strlength]; rand.NextBytes(strbuf); //fill the whole buffer with random bytes for (int __x__ = 0; __x__ < strlength; __x__++) { if (strbuf[__x__] == 0) //replace null chars with non-null random ones { strbuf[__x__] = (byte)(rand.Next(254) + 1); } } strbuf[strlength - 1] = 0; //null terminate error = Encoding.ASCII.GetString(strbuf); }
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; //path if (path == null) { path = new Messages.xamlamoveit_msgs.CartesianPath(); } pieces.Add(path.Serialize(true)); //transient thischunk = new byte[1]; thischunk[0] = (byte)((bool)transient ? 1 : 0); pieces.Add(thischunk); //element_path if (element_path == null) { element_path = ""; } scratch1 = Encoding.ASCII.GetBytes((string)element_path); 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); //display_name if (display_name == null) { display_name = ""; } scratch1 = Encoding.ASCII.GetBytes((string)display_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); //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 void Deserialize(byte[] serializedMessage, ref int currentIndex) { int arraylength = -1; bool hasmetacomponents = false; int piecesize = 0; byte[] thischunk, scratch1, scratch2; IntPtr h; object __thing; //path path = new Messages.xamlamoveit_msgs.CartesianPath(serializedMessage, ref currentIndex); //success success = serializedMessage[currentIndex++] == 1; //error error = ""; piecesize = BitConverter.ToInt32(serializedMessage, currentIndex); currentIndex += 4; error = Encoding.ASCII.GetString(serializedMessage, currentIndex, piecesize); currentIndex += piecesize; }
public override void Randomize() { int arraylength = -1; Random rand = new Random(); int strlength; byte[] strbuf, myByte; //paths arraylength = rand.Next(10); if (paths == null) { paths = new Messages.xamlamoveit_msgs.CartesianPath[arraylength]; } else { Array.Resize(ref paths, arraylength); } for (int i = 0; i < paths.Length; i++) { //paths[i] paths[i] = new Messages.xamlamoveit_msgs.CartesianPath(); paths[i].Randomize(); } //names arraylength = rand.Next(10); if (names == null) { names = new string[arraylength]; } else { Array.Resize(ref names, arraylength); } for (int i = 0; i < names.Length; i++) { //names[i] strlength = rand.Next(100) + 1; strbuf = new byte[strlength]; rand.NextBytes(strbuf); //fill the whole buffer with random bytes for (int __x__ = 0; __x__ < strlength; __x__++) { if (strbuf[__x__] == 0) //replace null chars with non-null random ones { strbuf[__x__] = (byte)(rand.Next(254) + 1); } } strbuf[strlength - 1] = 0; //null terminate names[i] = Encoding.ASCII.GetString(strbuf); } //element_paths arraylength = rand.Next(10); if (element_paths == null) { element_paths = new string[arraylength]; } else { Array.Resize(ref element_paths, arraylength); } for (int i = 0; i < element_paths.Length; i++) { //element_paths[i] strlength = rand.Next(100) + 1; strbuf = new byte[strlength]; rand.NextBytes(strbuf); //fill the whole buffer with random bytes for (int __x__ = 0; __x__ < strlength; __x__++) { if (strbuf[__x__] == 0) //replace null chars with non-null random ones { strbuf[__x__] = (byte)(rand.Next(254) + 1); } } strbuf[strlength - 1] = 0; //null terminate element_paths[i] = Encoding.ASCII.GetString(strbuf); } //success success = rand.Next(2) == 1; //error strlength = rand.Next(100) + 1; strbuf = new byte[strlength]; rand.NextBytes(strbuf); //fill the whole buffer with random bytes for (int __x__ = 0; __x__ < strlength; __x__++) { if (strbuf[__x__] == 0) //replace null chars with non-null random ones { strbuf[__x__] = (byte)(rand.Next(254) + 1); } } strbuf[strlength - 1] = 0; //null terminate error = Encoding.ASCII.GetString(strbuf); }
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; //paths hasmetacomponents |= true; if (paths == null) { paths = new Messages.xamlamoveit_msgs.CartesianPath[0]; } pieces.Add(BitConverter.GetBytes(paths.Length)); for (int i = 0; i < paths.Length; i++) { //paths[i] if (paths[i] == null) { paths[i] = new Messages.xamlamoveit_msgs.CartesianPath(); } pieces.Add(paths[i].Serialize(true)); } //names hasmetacomponents |= false; if (names == null) { names = new string[0]; } pieces.Add(BitConverter.GetBytes(names.Length)); for (int i = 0; i < names.Length; i++) { //names[i] if (names[i] == null) { names[i] = ""; } scratch1 = Encoding.ASCII.GetBytes((string)names[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); } //element_paths hasmetacomponents |= false; if (element_paths == null) { element_paths = new string[0]; } pieces.Add(BitConverter.GetBytes(element_paths.Length)); for (int i = 0; i < element_paths.Length; i++) { //element_paths[i] if (element_paths[i] == null) { element_paths[i] = ""; } scratch1 = Encoding.ASCII.GetBytes((string)element_paths[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); } //success thischunk = new byte[1]; thischunk[0] = (byte)((bool)success ? 1 : 0); pieces.Add(thischunk); //error if (error == null) { error = ""; } scratch1 = Encoding.ASCII.GetBytes((string)error); 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 void Deserialize(byte[] serializedMessage, ref int currentIndex) { int arraylength = -1; bool hasmetacomponents = false; int piecesize = 0; byte[] thischunk, scratch1, scratch2; IntPtr h; object __thing; //paths hasmetacomponents |= true; arraylength = BitConverter.ToInt32(serializedMessage, currentIndex); currentIndex += Marshal.SizeOf(typeof(System.Int32)); if (paths == null) { paths = new Messages.xamlamoveit_msgs.CartesianPath[arraylength]; } else { Array.Resize(ref paths, arraylength); } for (int i = 0; i < paths.Length; i++) { //paths[i] paths[i] = new Messages.xamlamoveit_msgs.CartesianPath(serializedMessage, ref currentIndex); } //names hasmetacomponents |= false; arraylength = BitConverter.ToInt32(serializedMessage, currentIndex); currentIndex += Marshal.SizeOf(typeof(System.Int32)); if (names == null) { names = new string[arraylength]; } else { Array.Resize(ref names, arraylength); } for (int i = 0; i < names.Length; i++) { //names[i] names[i] = ""; piecesize = BitConverter.ToInt32(serializedMessage, currentIndex); currentIndex += 4; names[i] = Encoding.ASCII.GetString(serializedMessage, currentIndex, piecesize); currentIndex += piecesize; } //element_paths hasmetacomponents |= false; arraylength = BitConverter.ToInt32(serializedMessage, currentIndex); currentIndex += Marshal.SizeOf(typeof(System.Int32)); if (element_paths == null) { element_paths = new string[arraylength]; } else { Array.Resize(ref element_paths, arraylength); } for (int i = 0; i < element_paths.Length; i++) { //element_paths[i] element_paths[i] = ""; piecesize = BitConverter.ToInt32(serializedMessage, currentIndex); currentIndex += 4; element_paths[i] = Encoding.ASCII.GetString(serializedMessage, currentIndex, piecesize); currentIndex += piecesize; } //success success = serializedMessage[currentIndex++] == 1; //error error = ""; piecesize = BitConverter.ToInt32(serializedMessage, currentIndex); currentIndex += 4; error = Encoding.ASCII.GetString(serializedMessage, currentIndex, piecesize); currentIndex += piecesize; }