/// <summary> /// The execute transaction inner. /// </summary> /// <param name="solution"> /// The solution. /// </param> /// <param name="textControl"> /// The text control. /// </param> public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl) { ITreeNode element = Utils.GetElementAtCaret(solution, textControl); if (element == null) { return; } IUsingList usingList = element.GetContainingNode(typeof(IUsingList), false) as IUsingList; if (usingList == null) { return; } ICSharpFile file = Utils.GetCSharpFile(solution, textControl); // This violation will only run if there are some using statements and definately at least 1 namespace // so [0] index will always be OK. ICSharpNamespaceDeclaration firstNamespace = file.NamespaceDeclarations[0]; foreach (IUsingDirective usingDirectiveNode in usingList.Imports) { firstNamespace.AddImportBefore(usingDirectiveNode, null); file.RemoveImport(usingDirectiveNode); } // Now sort the Usings into order. OrderUsingsBulbItem orderUsingsBulbItem = new OrderUsingsBulbItem(); orderUsingsBulbItem.ExecuteTransactionInner(solution, textControl); }