public static object DoInTransaction( IDesignerHost host, string transactionName, TransactionMethod transactionMethod, object parameter) { DesignerTransaction transaction = null; object RetVal = null; try { // Create a new designer transaction. transaction = host.CreateTransaction(transactionName); // Do the task polymorphically. RetVal = transactionMethod(host, parameter); } catch (CheckoutException ex) // something has gone wrong with transaction creation. { if (ex != CheckoutException.Canceled) throw ex; } catch { if (transaction != null) { transaction.Cancel(); transaction = null; // the transaction won't commit in the finally block. } throw; } finally { if (transaction != null) transaction.Commit(); } return RetVal; }
public virtual AbstractTransactionBuilder Method(TransactionMethod method) { ((ITransaction)element).Method = method; return(this); }