.net core2008. 8. 28. 11:18

public void BeginningOfFuction(CodeElement ce)
  {
   TextSelection ts = _applicationObject.ActiveDocument.Selection as TextSelection;

   if (ce == null)
    return;

   ts.MoveToPoint(ce.GetStartPoint(vsCMPart.vsCMPartBody), false);

   ts.Insert("\r\n", (int)vsInsertFlags.vsInsertFlagsInsertAtEnd);
   ts.Insert(
    string.Format(@"CSPSLogHelper.Write(LogLevel.Information, this, ""{0}"", ""{0} IN"");" + "\r\n"
    ,ce.Name)
    , (int)vsInsertFlags.vsInsertFlagsInsertAtStart);
   ts.SmartFormat();
  }

  public CodeElement EndOfFuction()
  {
   TextSelection ts = _applicationObject.ActiveDocument.Selection as TextSelection;
   CodeElement ce = ts.ActivePoint.get_CodeElement(vsCMElement.vsCMElementFunction);

   if (ce == null)
    return null;

   ts.MoveToPoint(ce.GetEndPoint(vsCMPart.vsCMPartBody), false);

   ts.Insert("\r\n", (int)vsInsertFlags.vsInsertFlagsInsertAtStart);
   ts.SmartFormat();
   ts.Insert(string.Format(@"CSPSLogHelper.Write(LogLevel.Information, this, ""{0}"", ""{0} OUT"");" + "\r\n"
    , ce.Name),
    (int)vsInsertFlags.vsInsertFlagsCollapseToEnd);
   ts.LineUp(true, 1);
   //ts.SelectLine();
   ts.SmartFormat();

   return ce;
  }

Posted by metalzone