Hi Derek,
I agree there should be some helpers to be used inside AutoCode, and that will be one of the new features of next version.
By now, there are still some ways to do what you say. For instance:
AddUsingThe following Code inserts a using statement at the beginning of the document.
Code: <Code id="AddUsing" codeElement="Document" codePoint="StartOfDocument" >
<![CDATA[using AnyNamespace;
]]>
</Code>
AddParameterA parameter can be inserted in a function overriding the Render method, it is, using the Render tag as follows:
Code: <Render>
CodeFunction cf = (CodeFunction) Selection.ActivePoint.get_CodeElement(vsCMElement.vsCMElementFunction);
cf.AddParameter("myParam", vsCMTypeRef.vsCMTypeRefInt, -1);
</Render>
The argument -1 means at the end of the argument list. You can change it for the ordinal position.
Implementing an InterfaceImplementing an Interface can be done positioning the cursor at the end of the class name, inserting
the <InterfaceName> text and executing the “Edit.ImplementInterfaceStubsImplicitly” command.
Code: <Execute>
// Get the start of class position
CodeElement ce = GetCodeElement(CodeElementTypes.Class);
TextPoint cp = GetCodePoint(ce, CodePositions.StartOfElement);
// Move Selection to that point
Selection.MoveToPoint(cp, false);
// Position to the end of the class name
Selection.EndOfLine(false);
// Write the interface name
Selection.Text = " : IDisposable";
// Let VS IDE implement the interface
DTE.ExecuteCommand("Edit.ImplementInterfaceStubsImplicitly", "");
</Execute>
Hope this could help,
Alvaro