Microsoft Developer Network > 포럼 홈 > Visual Studio Extensibility > Flavored Project: How to always add a custom project item to a certain folder
질문하기질문하기
 

답변됨Flavored Project: How to always add a custom project item to a certain folder

  • 2009년 7월 1일 수요일 오후 8:42Kenny Chinn 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Hello,
      In my flavored I have folders for each of my custom project items that I have created and when one of my custom project items are added to the project I want to them always be added to the correct folder. What is the best way to go about doing this? For example I have a item named "MyItem" so it should be added to the "MyItems" folder even if the user right clicks on the project node and adds the item from there.

    Thanks
    Kenny

답변

  • 2009년 7월 1일 수요일 오후 10:24Rusty Deschenes중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    Hi Kenny,

    One option would be to listen to item added (and potentially rename) events and when those happen do your filtering and if the item needs to be somewhere else leverage the cut and paste commands to move it to the folder where you want it to be.

    An alternative would be to overwrite all the code path that can cause items to be added (and this assume the the project you are flavoring doesn't ever add anything through internal method which you can't overwrite) and do the filtering at that point. A good starting point for that would be to control the automation objects.

    Rusty

모든 응답

  • 2009년 7월 1일 수요일 오후 10:24Rusty Deschenes중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    Hi Kenny,

    One option would be to listen to item added (and potentially rename) events and when those happen do your filtering and if the item needs to be somewhere else leverage the cut and paste commands to move it to the folder where you want it to be.

    An alternative would be to overwrite all the code path that can cause items to be added (and this assume the the project you are flavoring doesn't ever add anything through internal method which you can't overwrite) and do the filtering at that point. A good starting point for that would be to control the automation objects.

    Rusty