// Higher level code die gebruik maakt van mijn TransactionContext
using (TransactionContext tc =
new TransactionContext
() ) {
tc.setProperty("PROP1", "value1");
tc.setProperty("PROP2", "value2");
tc.setProperty("PROP3", "value3");
throw UnexpectedException();
tc.setProperty("PROP4", "value4");
}
// Vertaling
try
{
TransactionContext tc =
new TransactionContext
();
tc.setProperty("PROP1", "value1");
tc.setProperty("PROP2", "value2");
tc.setProperty("PROP3", "value3");
throw UnexpectedException();
tc.setProperty("PROP4", "value4");
}
finally
{
tc.Dispose();
}
// Wat ik dus zou moeten doen
public class TransactionContext
{
public override void Dispose()
{
PushAllPropertyChangesToDB();
}
}
// Maar ik wil geen PushAllPropertyChanges als een exception gegooid werd in mijn try block