本文整理汇总了C#中IPythonInterpreterFactory.CreateInterpreter方法的典型用法代码示例。如果您正苦于以下问题:C# IPythonInterpreterFactory.CreateInterpreter方法的具体用法?C# IPythonInterpreterFactory.CreateInterpreter怎么用?C# IPythonInterpreterFactory.CreateInterpreter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPythonInterpreterFactory
的用法示例。
在下文中一共展示了IPythonInterpreterFactory.CreateInterpreter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnalysisView
public AnalysisView(
string dbDir,
Version version = null,
bool withContention = false,
bool withRecursion = false
) {
var paths = new List<string>();
paths.Add(dbDir);
while (!File.Exists(IOPath.Combine(paths[0], "__builtin__.idb")) &&
!File.Exists(IOPath.Combine(paths[0], "builtins.idb"))) {
var upOne = IOPath.GetDirectoryName(paths[0]);
if (string.IsNullOrEmpty(upOne) || upOne == paths[0]) {
break;
}
paths.Insert(0, upOne);
}
if (withRecursion) {
paths.AddRange(Directory.EnumerateDirectories(dbDir, "*", SearchOption.AllDirectories));
}
if (version == null) {
if (File.Exists(IOPath.Combine(paths[0], "builtins.idb"))) {
version = new Version(3, 3);
} else {
version = new Version(2, 7);
}
}
_factory = InterpreterFactoryCreator.CreateAnalysisInterpreterFactory(
version,
dbDir,
paths.ToArray()
);
Path = dbDir;
_interpreter = _factory.CreateInterpreter();
_context = _interpreter.CreateModuleContext();
var modNames = _interpreter.GetModuleNames();
IEnumerable<Tuple<string, string>> modItems;
if (!withRecursion) {
modItems = modNames
.Select(n => Tuple.Create(n, IOPath.Combine(dbDir, n + ".idb")))
.Where(t => File.Exists(t.Item2));
} else {
modItems = modNames
.Select(n => Tuple.Create(
n,
Directory.EnumerateFiles(dbDir, n + ".idb", SearchOption.AllDirectories).FirstOrDefault()
))
.Where(t => File.Exists(t.Item2));
}
var stopwatch = new Stopwatch();
stopwatch.Start();
if (withContention) {
modItems = modItems
.AsParallel()
.WithExecutionMode(ParallelExecutionMode.ForceParallelism);
}
_modules = modItems
.Select(t => new ModuleView(_interpreter, _context, t.Item1, t.Item2))
.OrderBy(m => m.SortKey)
.ThenBy(m => m.Name)
.ToList<IAnalysisItemView>();
stopwatch.Stop();
_modules.Insert(0, new KnownTypesView(_interpreter, version));
LoadMilliseconds = stopwatch.ElapsedMilliseconds;
TopLevelModuleCount = _modules.Count - 1;
}
示例2: VsProjectAnalyzer
internal VsProjectAnalyzer(
IServiceProvider serviceProvider,
IPythonInterpreterFactory factory,
IPythonInterpreterFactory[] allFactories)
: this(serviceProvider, factory.CreateInterpreter(), factory, allFactories) {
}
示例3: BaseAnalysisTest
public BaseAnalysisTest(IPythonInterpreterFactory factory)
: this(factory, factory.CreateInterpreter()) {
}