/// <exception cref="System.Exception"></exception> private void AssertReadWriteAheadFileEnd(IoAdapter adapter, string str) { var data = Runtime.GetBytesForString(str); var read = new byte[2048]; adapter.Seek(10); var readBytes = adapter.Read(data); Assert.AreEqual(-1, readBytes); Assert.AreEqual(0, adapter.GetLength()); adapter.Seek(0); readBytes = adapter.Read(data); Assert.AreEqual(-1, readBytes); Assert.AreEqual(0, adapter.GetLength()); adapter.Seek(10); adapter.Write(data); Assert.AreEqual(10 + data.Length, adapter.GetLength()); adapter.Seek(0); readBytes = adapter.Read(read); Assert.AreEqual(10 + data.Length, readBytes); adapter.Seek(20 + data.Length); readBytes = adapter.Read(read); Assert.AreEqual(-1, readBytes); adapter.Seek(1024 + data.Length); readBytes = adapter.Read(read); Assert.AreEqual(-1, readBytes); adapter.Seek(1200); adapter.Write(data); adapter.Seek(0); readBytes = adapter.Read(read); Assert.AreEqual(1200 + data.Length, readBytes); }
protected virtual void Open(bool readOnly) { if (null != _adapter) { throw new InvalidOperationException(); } _adapter = Factory().Open(TempFile(), false, 0, readOnly); }
protected virtual void Close() { if (null != _adapter) { _adapter.Close(); _adapter = null; } }
public LoggingIoAdapter(IoAdapter delegateAdapter, string fileName, int config, TextWriter existingOut) : base(delegateAdapter) { _fileName = fileName; _out = existingOut; _config = config; }
/// <exception cref="System.Exception"></exception> private void AssertReadWriteString(IoAdapter adapter, string str) { byte[] data = Sharpen.Runtime.GetBytesForString(str); byte[] read = new byte[2048]; adapter.Seek(0); adapter.Write(data); adapter.Seek(0); adapter.Read(read); Assert.AreEqual(str, Sharpen.Runtime.GetStringForBytes(read, 0, data.Length)); }
public LogReplayer(String logFilePath, IoAdapter io, ISet commands) { _logFilePath = logFilePath; _io = io; _commands = commands; _counts = new Hashtable(); foreach (object com in commands) { _counts[com] = (Int64)0; } }
public LoggingIoAdapter(IoAdapter delegateAdapter, string fileName, int config) : base(delegateAdapter) { _fileName = fileName; try { _out = new StreamWriter(new FileStream(fileName, FileMode.Append, FileAccess.Write)); } catch (FileNotFoundException e) { throw new Db4oIOException(e); } _config = config; }
public virtual void TestGrowth() { MemoryIoAdapter factory = new MemoryIoAdapter(); factory.GrowBy(GrowBy); IoAdapter io = factory.Open(Url, false, 0, false); AssertLength(factory, 0); WriteBytes(io, GrowBy - 1); AssertLength(factory, GrowBy); WriteBytes(io, GrowBy - 1); AssertLength(factory, GrowBy * 2); WriteBytes(io, GrowBy * 2); AssertLength(factory, GrowBy * 4 - 2); }
public LoggingIoAdapter(IoAdapter delegateAdapter, string fileName) : this(delegateAdapter , fileName, LogAll) { }
private LoggingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long initialLength, string fileName, int config, TextWriter existingOut) : this(delegateAdapter.Open(path, lockFile , initialLength, false), fileName, config, existingOut) { }
public virtual void Replay(IoAdapter adapter) { adapter.Sync(); }
public void Io(IoAdapter adapter) { GlobalSettingOnly(); Storage = new IoAdapterStorage(adapter); }
public virtual void Replay(IoAdapter adapter) { adapter.Write(PrepareBuffer()); }
public DelayingIoAdapter(IoAdapter delegateAdapter, Delays delays) : base(delegateAdapter ) { _delays = delays; _timing = new TicksTiming(); }
private void AssertReadOnly(IoAdapter adapter) { Assert.Expect(typeof(Db4oIOException), new _ICodeBlock_21(adapter)); }
public LogReplayer(String logFilePath, IoAdapter io) : this(logFilePath, io, LogConstants.AllEntries()) { }
public virtual void Replay(IoAdapter adapter) { adapter.Seek(_address); }
public virtual void Replay(IoAdapter adapter) { adapter.Read(PrepareBuffer(), _length); }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> public DelayingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long initialLength, Delays delays) : this(delegateAdapter.Open(path, lockFile, initialLength , false), delays) { }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> public DelayingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long initialLength) : this(delegateAdapter, path, lockFile, initialLength, _delays) { }
private void WriteBytes(IoAdapter io, int numBytes) { io.Write(new byte[numBytes]); }
public _ICodeBlock_21(IoAdapter adapter) { this.adapter = adapter; }
public DelayingIoAdapter(IoAdapter delegateAdapter) : this(delegateAdapter, _delays ) { }