本文整理汇总了C#中EnvDTE.GetPythonProject方法的典型用法代码示例。如果您正苦于以下问题:C# EnvDTE.GetPythonProject方法的具体用法?C# EnvDTE.GetPythonProject怎么用?C# EnvDTE.GetPythonProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnvDTE
的用法示例。
在下文中一共展示了EnvDTE.GetPythonProject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenProject
internal void OpenProject(VisualStudioApp app, string slnName, out PythonProjectNode projectNode, out EnvDTE.Project dteProject) {
PythonVersion.AssertInstalled();
dteProject = app.OpenProject("TestData\\Targets\\" + slnName);
projectNode = dteProject.GetPythonProject();
var fact = projectNode.InterpreterFactories.Where(x => x.Configuration.Id == PythonVersion.Id).FirstOrDefault();
Assert.IsNotNull(fact, "Project does not contain expected interpreter");
projectNode.ActiveInterpreter = fact;
dteProject.Save();
}
示例2: EnvironmentReplWorkingDirectoryTest
private void EnvironmentReplWorkingDirectoryTest(
PythonVisualStudioApp app,
EnvDTE.Project project,
TreeNode env,
string envName
) {
var path1 = Path.Combine(Path.GetDirectoryName(project.FullName), Guid.NewGuid().ToString("N"));
var path2 = Path.Combine(Path.GetDirectoryName(project.FullName), Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(path1);
Directory.CreateDirectory(path2);
env.Select();
app.Dte.ExecuteCommand("Python.Interactive");
var window = app.GetInteractiveWindow(string.Format("{0} Interactive", envName));
Assert.IsNotNull(window, string.Format("Failed to find '{0} Interactive'", envName));
try {
app.ServiceProvider.GetUIThread().Invoke(() => project.GetPythonProject().SetProjectProperty("WorkingDirectory", path1));
window.Reset();
window.ReplWindow.Evaluator.ExecuteText("import os; os.getcwd()").Wait();
window.WaitForTextEnd(
string.Format("'{0}'", path1.Replace("\\", "\\\\")),
">>>"
);
app.ServiceProvider.GetUIThread().Invoke(() => project.GetPythonProject().SetProjectProperty("WorkingDirectory", path2));
window.Reset();
window.ReplWindow.Evaluator.ExecuteText("import os; os.getcwd()").Wait();
window.WaitForTextEnd(
string.Format("'{0}'", path2.Replace("\\", "\\\\")),
">>>"
);
} finally {
window.Close();
}
}
示例3: LaunchFileFromProject
public static SD.Process LaunchFileFromProject(VisualStudioApp app, EnvDTE.Project project, string filename, string interpreterArgs, string programArgs) {
var item = project.ProjectItems.Item(filename);
var window = item.Open();
window.Activate();
var doc = item.Document;
var docFN = doc.FullName;
string fullFilename = Path.GetFullPath(docFN);
string cmdlineArgs = String.Format("{0} \"{1}\" {2}", interpreterArgs, fullFilename, programArgs);
var uiThread = app.GetService<UIThreadBase>();
var projectInterpreter = uiThread.Invoke(() => project.GetPythonProject().GetLaunchConfigurationOrThrow().GetInterpreterPath());
var psi = new SD.ProcessStartInfo(projectInterpreter, cmdlineArgs);
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
var p = SD.Process.Start(psi);
p.EnableRaisingEvents = true;
string output = "";
p.OutputDataReceived += (sender, args) => {
output += args.Data;
};
p.ErrorDataReceived += (sender, args) => {
output += args.Data;
};
p.BeginErrorReadLine();
p.BeginOutputReadLine();
p.Exited += (sender, args) => {
SD.Debug.WriteLine("Process Id ({0}) exited with ExitCode: {1}", p.Id, p.ExitCode);
SD.Debug.WriteLine(String.Format("Output: {0}", output));
};
Assert.IsNotNull(p, "Failure to start process, {0} {1} ", projectInterpreter, cmdlineArgs);
return p;
}