当前位置: 首页>>代码示例>>C#>>正文


C# IPythonInterpreterFactory.CreateInterpreter方法代码示例

本文整理汇总了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;
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:73,代码来源:AnalysisView.cs

示例2: VsProjectAnalyzer

 internal VsProjectAnalyzer(
     IServiceProvider serviceProvider,
     IPythonInterpreterFactory factory,
     IPythonInterpreterFactory[] allFactories)
     : this(serviceProvider, factory.CreateInterpreter(), factory, allFactories) {
 }
开发者ID:omnimark,项目名称:PTVS,代码行数:6,代码来源:ProjectAnalyzer.cs

示例3: BaseAnalysisTest

 public BaseAnalysisTest(IPythonInterpreterFactory factory)
     : this(factory, factory.CreateInterpreter()) {
 }
开发者ID:RussBaz,项目名称:PTVS,代码行数:3,代码来源:BaseAnalysisTest.cs


注:本文中的IPythonInterpreterFactory.CreateInterpreter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。