public FileMultiCheckpoint(string filename, string name, int bestCount)
        {
            Ensure.NotNullOrEmpty(filename, "filename");
            Ensure.NotNull(name, "name");
            Ensure.Positive(bestCount, "bestCount");

            _filename = filename;
            _name = name;
            _memCheckpoint = new InMemMultiCheckpoint(string.Format("{0} - InMem", name), bestCount);

            _fileStream = new FileStream(_filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);

            if (_fileStream.Length % EntrySize != 0)
            {
                throw new Exception(
                        string.Format("MultiCheckpoint file '{0}' has length {1} not divisible by EntrySize ({2}).",
                                      _filename,
                                      _fileStream.Length,
                                      EntrySize));
            }

            _reader = new BinaryReader(_fileStream);
            _writer = new BinaryWriter(_fileStream);

            ReadCheckpoints((int)_fileStream.Length / EntrySize);
        }
Exemple #2
0
        public FileMultiCheckpoint(string filename, string name, int bestCount)
        {
            Ensure.NotNullOrEmpty(filename, "filename");
            Ensure.NotNull(name, "name");
            Ensure.Positive(bestCount, "bestCount");

            _filename      = filename;
            _name          = name;
            _memCheckpoint = new InMemMultiCheckpoint(string.Format("{0} - InMem", name), bestCount);

            _fileStream = new FileStream(_filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);

            if (_fileStream.Length % EntrySize != 0)
            {
                throw new Exception(
                          string.Format("MultiCheckpoint file '{0}' has length {1} not divisible by EntrySize ({2}).",
                                        _filename,
                                        _fileStream.Length,
                                        EntrySize));
            }

            _reader = new BinaryReader(_fileStream);
            _writer = new BinaryWriter(_fileStream);

            ReadCheckpoints((int)_fileStream.Length / EntrySize);
        }
 public void SetUp()
 {
     _checkpoint = new InMemMultiCheckpoint(3);
 }