42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
|
|
namespace Lucidiot.Raima {
|
|
public class MemoryStorage : IDatabaseStorage {
|
|
private Dictionary<string, MemoryStream> _files = new Dictionary<string,MemoryStream>();
|
|
|
|
#region IDatabaseStorage Members
|
|
|
|
public bool CanRead {
|
|
get { return true; }
|
|
}
|
|
|
|
public bool CanWrite {
|
|
get { return true; }
|
|
}
|
|
|
|
public bool Exists(string fileName) {
|
|
return _files.ContainsKey(fileName);
|
|
}
|
|
|
|
public BinaryReader GetReader(string fileName) {
|
|
if (!_files.ContainsKey(fileName))
|
|
_files[fileName] = new MemoryStream();
|
|
return new BinaryReader(_files[fileName]);
|
|
}
|
|
|
|
public BinaryWriter GetWriter(string fileName) {
|
|
if (!_files.ContainsKey(fileName))
|
|
_files[fileName] = new MemoryStream();
|
|
return new BinaryWriter(_files[fileName]);
|
|
}
|
|
|
|
public void Delete(string fileName) {
|
|
_files.Remove(fileName);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|