Advertisement
Guest User

CodeModeltesting

a guest
Dec 29th, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. /*
  2.  * Create a new c# project, add references to envdte
  3.  *
  4.  * Add A C++ project to the existing solution
  5.  * with an empty source file, test.cpp lying under ROOT*/
  6.  
  7. namespace CodeModeltesting
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             EnvDTE.DTE dte = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.12.0");
  14.             System.Console.Write(dte.Solution.Projects.Count);
  15.  
  16.             var project = dte.Solution.Projects.Item(2);
  17.  
  18.             foreach (EnvDTE.ProjectItem item in project.ProjectItems)
  19.             {
  20.                 if (item.Name == "test.cpp")
  21.                 {
  22.                     EnvDTE.FileCodeModel model = item.FileCodeModel;
  23.                     model.AddFunction("X::X", EnvDTE.vsCMFunction.vsCMFunctionConstructor, null, -1);
  24.                     item.ContainingProject.Save();
  25.                     break;
  26.                 }
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement