/// <summary> /// Generates a List of FixedQueues of StateDescriptors from the given byte buffer. /// </summary> /// <param name="buffer"></param> /// <returns></returns> private static List <FixedQueue <StateDescriptor> > ReadStates(byte[] buffer) { IFormatter formatter = new BinaryFormatter(); List <FixedQueue <StateDescriptor> > states = new List <FixedQueue <StateDescriptor> >(); int stateSize = System.Runtime.InteropServices.Marshal.SizeOf(new StateDescriptor()); MemoryStream ms = new MemoryStream(buffer); while (ms.Position < ms.Length) { FixedQueue <StateDescriptor> currentStates = new FixedQueue <StateDescriptor>(Tracker.Length); for (int i = 0; i < Tracker.Length; i++) { currentStates.Add((StateDescriptor)formatter.Deserialize(ms)); } states.Add(currentStates); } return(states); }