public static void WithTransaction( IKLink link, params Action<IKLink>[] actions ) { try { Console.WriteLine( "\n===== Transaction started..." ); link.TransactionStart(); foreach( var action in actions ) action( link ); link.TransactionCommit(); Console.WriteLine( "\n===== Transaction committed..." ); } catch { link.TransactionAbort(); throw; } }
static void _NestedListTransaction( IKLink link, List<Action<IKLink>> actions ) { Action<IKLink> action = actions.Count == 0 ? null : actions[0]; if( action == null ) return; try { Console.WriteLine( "\n===== Transaction started..." ); link.TransactionStart(); action( link ); actions.Remove( action ); _NestedListTransaction( link, actions ); link.TransactionCommit(); Console.WriteLine( "\n===== Transaction committed..." ); } catch { link.TransactionAbort(); throw; } }