public int GetFreshId()
{
lock (this.GetType ()) {
var fileName = Path.Combine (this.directory, "LastKey");
int newKey;
if (!File.Exists (fileName)) {
newKey = 1;
} else {
var str = File.ReadAllText (fileName);
newKey = int.Parse (str) + 1;
}
File.WriteAllText (fileName, newKey.ToString ());
return newKey;
}
}
static Session FreshSession(FileSystemDatabase fsd, Shovel.Instruction[] bytecode, string program) { var session = new Session(); session.Id = fsd.GetFreshId(); session.ShovelVmSources = program; session.ShovelVmBytecode = Shovel.Api.SerializeBytecode(bytecode); return(session); }