Answered Visual Studio addin - get the whole code

  • Saturday, June 23, 2012 6:54 PM
     
     

    I write a Add-in for visual studio 2010.

    I want to copy the code in a variable like:

    string code = _applicationObject.ActiveWindow.xxx();

    //instead of xxx() i want the written code.

    code = MyFormatCodeFunction(code);

    _applicationObject.ActiveWindow.yyy();

    // instead of yyy() i want to set the formatted code

All Replies

  • Sunday, June 24, 2012 5:15 PM
     
     
    No ideas?
  • Sunday, June 24, 2012 6:25 PM
    Moderator
     
     

    It isn't clear what you are asking for.  What do you mean 'copy code in a variable'? In the example you show there is no variable, there is a method invocation on the ActiveWindow object. You would need to be more explicit in what you are trying to do in order for someone to offer advice.

    Ryan

  • Tuesday, June 26, 2012 1:49 AM
    Moderator
     
     Answered

    I think you are looking for the code model which you can access the code in the editor (document). You can get the exact code of a method there and write back after modifing.

    Get started from Discovering Code by Using the Code Model (Visual C#)

  • Tuesday, July 03, 2012 7:40 AM
    Moderator
     
     

    Hi buuhuu33,

    I will mask Yi's reply as the answer.

    If it is not the answer you want. Please unmark it.

    Thanks,


    Ego [MSFT]
    MSDN Community Support | Feedback to us