public override void Randomize() { int arraylength = -1; Random rand = new Random(); int strlength; byte[] strbuf, myByte; //groups arraylength = rand.Next(10); if (groups == null) { groups = new Messages.dynamic_reconfigure.Group[arraylength]; } else { Array.Resize(ref groups, arraylength); } for (int i = 0; i < groups.Length; i++) { //groups[i] groups[i] = new Messages.dynamic_reconfigure.Group(); groups[i].Randomize(); } //max max = new Messages.dynamic_reconfigure.Config(); max.Randomize(); //min min = new Messages.dynamic_reconfigure.Config(); min.Randomize(); //dflt dflt = new Messages.dynamic_reconfigure.Config(); dflt.Randomize(); }
public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex) { int arraylength = -1; bool hasmetacomponents = false; object __thing; int piecesize = 0; byte[] thischunk, scratch1, scratch2; IntPtr h; //groups hasmetacomponents |= true; arraylength = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex); currentIndex += Marshal.SizeOf(typeof(System.Int32)); if (groups == null) { groups = new Messages.dynamic_reconfigure.Group[arraylength]; } else { Array.Resize(ref groups, arraylength); } for (int i = 0; i < groups.Length; i++) { //groups[i] groups[i] = new Messages.dynamic_reconfigure.Group(SERIALIZEDSTUFF, ref currentIndex); } //max max = new Messages.dynamic_reconfigure.Config(SERIALIZEDSTUFF, ref currentIndex); //min min = new Messages.dynamic_reconfigure.Config(SERIALIZEDSTUFF, ref currentIndex); //dflt dflt = new Messages.dynamic_reconfigure.Config(SERIALIZEDSTUFF, ref currentIndex); }
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; //groups hasmetacomponents |= true; if (groups == null) { groups = new Messages.dynamic_reconfigure.Group[0]; } pieces.Add(BitConverter.GetBytes(groups.Length)); for (int i = 0; i < groups.Length; i++) { //groups[i] if (groups[i] == null) { groups[i] = new Messages.dynamic_reconfigure.Group(); } pieces.Add(groups[i].Serialize(true)); } //max if (max == null) { max = new Messages.dynamic_reconfigure.Config(); } pieces.Add(max.Serialize(true)); //min if (min == null) { min = new Messages.dynamic_reconfigure.Config(); } pieces.Add(min.Serialize(true)); //dflt if (dflt == null) { dflt = new Messages.dynamic_reconfigure.Config(); } pieces.Add(dflt.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); }