Transaction support

Feb 16, 2011 at 5:31 PM
Edited Feb 16, 2011 at 5:32 PM

Hi,

i think we can use an implementation of System.Transaction.IEnlistmentNotification for the FileSystemDatabase (xml or json) to support transaction (commit, rollback...)

for example we could override the Write<T> like this with the .Net Transactional File Manager

 

public override string Write<T>(T row, string id)
{
                        IFileManager fileManager = new TxFileManager();

			string filename = CreateFilename(typeof(T), id);
			Formatting formatting = Formatting.None;
			if (WriteIndented)
			{
				formatting = Formatting.Indented;
			}
			string output = JsonConvert.SerializeObject(row, formatting);
                        
//lock (syncLock) // { // File.WriteAllText(filename, output); // } fileManager.WriteAllText(filename, output); return filename; }

what do you think ?

Coordinator
Feb 17, 2011 at 11:39 AM

Nice idea.

Firstly I would refactor the "write/read all text" parts to a strategy based implementation defaulting to the standard windows method that is current. Then I would add a strategy for the transactional imp.

It would be a good addition because I have always hade Silverlights isolated storage in mind too... :-)