/// <summary> /// Moves the using statements. /// </summary> /// <param name="instance">The instance.</param> public static void MoveUsingStatements(this ProjectItem instance) { TraceService.WriteLine("ProjectItemExtensions::MoveUsingStatements in file " + instance.Name); List <string> usingStatements = new List <string>(); try { foreach (CodeElement codeElement in instance.FileCodeModel.CodeElements) { //// assume the using statements come before the required namespace. switch (codeElement.Kind) { case vsCMElement.vsCMElementImportStmt: TextPoint startPoint = codeElement.StartPoint; TextPoint endPoint = codeElement.EndPoint; string text = startPoint.CreateEditPoint().GetText(endPoint); usingStatements.Add(text); break; case vsCMElement.vsCMElementNamespace: TextPoint nameSpacePoint = codeElement.GetStartPoint(vsCMPart.vsCMPartBody); EditPoint editPoint = nameSpacePoint.CreateEditPoint(); foreach (string statement in usingStatements) { editPoint.Insert("\t" + statement + "\n"); } break; } } instance.DeleteNameSpaceUsingStatements(); } catch (Exception exception) { TraceService.WriteError("MoveUsingStatements " + exception.Message); } }