Process the extraction in an transaction.

Topics: Developer Forum, Project Management Forum, User Forum
Jul 8, 2008 at 12:19 PM
I would like to have the option to put the whole refactor action in one transaction. (perhaps a checkbox to enable/disable this option).
The main advantage would be that I can undo the refactor of 20 strings with one single CTRL+Z keypress.

I haven't looked at the inner workings of the tool but for a VisualStudio Add0-in  I once wrote I used the following code.

//get designer host.
System.ComponentModel.Design.IDesignerHost
objIDesignerHost = (System.ComponentModel.Design.IDesignerHost)_applicationObject.ActiveDocument.ActiveWindow.Object;
//begin transaction
DesignerTransaction trans = objIDesignerHost.CreateTransaction();

 

try
{
  //DO STUFF
}
catch
{
  if (trans != null)
    trans.Cancel();
    trans =
null;
}
finally{
  if (trans != null)
    trans.Commit();
}

Greetings and thanx for the tool, Kabwla