Пример #1
0
        public static bool Save(string filename, string currentWorkspace)
        {
            try
            {
                Stream          stream    = File.Open(filename, FileMode.Create);
                BinaryFormatter formatter = new BinaryFormatter();

                // Save the workspace.
                formatter.Serialize(stream, currentWorkspace);

                // Save all agent instances.
                AgentInstancePool.Serialize(stream, formatter);

                // Save all parameters.
                Serialize(stream, formatter);
                formatter.Serialize(stream, TotalFrames);

                // Save all frame states.
                FrameStatePool.Serialize(stream, formatter);

                // Save all messages.
                MessageQueue.Serialize(stream, formatter);

                stream.Close();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #2
0
        public static bool LoadDump(string filename, string currentWorkspace)
        {
            try
            {
                Stream          stream    = File.Open(filename, FileMode.Open);
                BinaryFormatter formatter = new BinaryFormatter();

                // Load the workspace.
                currentWorkspace = formatter.Deserialize(stream) as string;

                if (Plugin.WorkspaceDelegateHandler != null)
                {
                    Plugin.WorkspaceDelegateHandler(currentWorkspace, false);
                }

                // Load all agent instances.
                AgentInstancePool.Deserialize(stream, formatter);

                // Load all parameters.
                Deserialize(stream, formatter);
                TotalFrames  = (int)formatter.Deserialize(stream);
                CurrentFrame = 0;

                // Load all frame states.
                FrameStatePool.Deserialize(stream, formatter);

                // Load all messages.
                MessageQueue.Deserialize(stream, formatter);

                stream.Close();

                return(true);
            }
            catch (Exception ex)
            {
                string msgError = string.Format(Resources.LoadDebugDataError, filename, ex.Message);
                MessageBox.Show(msgError, Resources.LoadError, MessageBoxButtons.OK);
            }

            return(false);
        }