本文整理汇总了C#中ProjectInfo.GetInterpreters方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectInfo.GetInterpreters方法的具体用法?C# ProjectInfo.GetInterpreters怎么用?C# ProjectInfo.GetInterpreters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectInfo
的用法示例。
在下文中一共展示了ProjectInfo.GetInterpreters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DiscoverInterpreters
/// <summary>
/// Call to find interpreters in the associated project. Separated from
/// the constructor to allow exceptions to be handled without causing
/// the project node to be invalid.
/// </summary>
private bool DiscoverInterpreters(ProjectInfo projectInfo) {
// <Interpreter Include="InterpreterDirectory">
// <Id>factoryProviderId;interpreterFactoryId</Id>
// <Version>...</Version>
// <InterpreterPath>...</InterpreterPath>
// <WindowsInterpreterPath>...</WindowsInterpreterPath>
// <PathEnvironmentVariable>...</PathEnvironmentVariable>
// <Description>...</Description>
// </Interpreter>
var projectHome = PathUtils.GetAbsoluteDirectoryPath(
Path.GetDirectoryName(projectInfo.FullPath),
projectInfo.GetPropertyValue("ProjectHome")
);
var factories = new Dictionary<string, FactoryInfo>();
foreach (var item in projectInfo.GetInterpreters()) {
// Errors in these options are fatal, so we set anyError and
// continue with the next entry.
var dir = GetValue(item, "EvaluatedInclude");
if (!PathUtils.IsValidPath(dir)) {
Log("Interpreter has invalid path: {0}", dir ?? "(null)");
continue;
}
dir = PathUtils.GetAbsoluteDirectoryPath(projectHome, dir);
var id = GetValue(item, MSBuildConstants.IdKey);
if (string.IsNullOrEmpty(id)) {
Log("Interpreter {0} has invalid value for '{1}': {2}", dir, MSBuildConstants.IdKey, id);
continue;
}
if (factories.ContainsKey(id)) {
Log("Interpreter {0} has a non-unique id: {1}", dir, id);
continue;
}
var verStr = GetValue(item, MSBuildConstants.VersionKey);
Version ver;
if (string.IsNullOrEmpty(verStr) || !Version.TryParse(verStr, out ver)) {
Log("Interpreter {0} has invalid value for '{1}': {2}", dir, MSBuildConstants.VersionKey, verStr);
continue;
}
// The rest of the options are non-fatal. We create an instance
// of NotFoundError with an amended description, which will
// allow the user to remove the entry from the project file
// later.
bool hasError = false;
var description = GetValue(item, MSBuildConstants.DescriptionKey);
if (string.IsNullOrEmpty(description)) {
description = PathUtils.CreateFriendlyDirectoryPath(projectHome, dir);
}
var path = GetValue(item, MSBuildConstants.InterpreterPathKey);
if (!PathUtils.IsValidPath(path)) {
Log("Interpreter {0} has invalid value for '{1}': {2}", dir, MSBuildConstants.InterpreterPathKey, path);
hasError = true;
} else if (!hasError) {
path = PathUtils.GetAbsoluteFilePath(dir, path);
}
var winPath = GetValue(item, MSBuildConstants.WindowsPathKey);
if (!PathUtils.IsValidPath(winPath)) {
Log("Interpreter {0} has invalid value for '{1}': {2}", dir, MSBuildConstants.WindowsPathKey, winPath);
hasError = true;
} else if (!hasError) {
winPath = PathUtils.GetAbsoluteFilePath(dir, winPath);
}
var pathVar = GetValue(item, MSBuildConstants.PathEnvVarKey);
if (string.IsNullOrEmpty(pathVar)) {
pathVar = "PYTHONPATH";
}
var arch = InterpreterArchitecture.TryParse(GetValue(item, MSBuildConstants.ArchitectureKey));
string fullId = GetInterpreterId(projectInfo.FullPath, id);
FactoryInfo info;
if (hasError) {
info = new ErrorFactoryInfo(fullId, ver, description, dir);
} else {
info = new ConfiguredFactoryInfo(this, new InterpreterConfiguration(
fullId,
description,
dir,
path,
winPath,
pathVar,
arch,
ver,
InterpreterUIMode.CannotBeDefault | InterpreterUIMode.CannotBeConfigured | InterpreterUIMode.SupportsDatabase
));
}
MergeFactory(projectInfo, factories, info);
//.........这里部分代码省略.........