private static Logbook LoadLogbook(Store s, ulong seq) { // The record isn't authoritive. Don't bother checking. // if(!s.MasterInfo.LogbookSequence.Contains(seq)) return new Logbook(s.MasterInfo.MemberId, seq); var file = Path.Combine(_dataDir, LogbookFilename(s.MemberId, seq)); if (File.Exists(file)) { try { using (Stream input = File.OpenRead(file)) { //check header byte[] buf = new byte[8]; input.ReadFully(buf); if (buf.SequenceEqual(_logHeader)) { //deserialize using (DSReader rdr = new DSReader(input, true)) { return(new Logbook(Premitives.StoragePremitive.Parse(rdr), new LinkedList <object>())); } } } } catch (IOException) { //Fall through. } } var newBook = new Logbook(s.MemberId, seq); s._dirtyLogbooks.Add(newBook); return(newBook); }
public ILogbook this[ulong seq] { get { if (seq == 0) { return(_store.Weekbook); } WeakReference <Logbook> _reference; if (_store._logbooks.TryGetValue(seq, out _reference)) { Logbook _target; if (_reference.TryGetTarget(out _target)) { return(_target); } } Logbook newBook = LoadLogbook(_store, seq); _store._logbooks[seq] = new WeakReference <Logbook>(newBook); _store._logbookSequence.Add(seq); _store._dirtyLogbooks.Add(newBook); //TODO Remove this. return(newBook); } }
public ILogbook this[ulong seq] { get { if (seq == 0) { return(_store.Weekbook); } WeakReference <Logbook> _reference; if (_store._logbooks.TryGetValue(seq, out _reference)) { Logbook _target; if (_reference.TryGetTarget(out _target)) { return(_target); } } Logbook newBook = LoadLogbook(_store, seq); _store._logbooks[seq] = new WeakReference <Logbook>(newBook); System.Windows.Application.Current.Dispatcher.Invoke(() => _store._logbookSequence.Add(seq), System.Windows.Threading.DispatcherPriority.Send); _store._dirtyLogbooks.Add(newBook); //TODO Remove this. return(newBook); } }
public ShipsAccessor(Logbook lbk) { this.lbk = lbk; }