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


C# IServiceProvider.GetPythonToolsService方法代码示例

本文整理汇总了C#中IServiceProvider.GetPythonToolsService方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceProvider.GetPythonToolsService方法的具体用法?C# IServiceProvider.GetPythonToolsService怎么用?C# IServiceProvider.GetPythonToolsService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServiceProvider的用法示例。


在下文中一共展示了IServiceProvider.GetPythonToolsService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EnsureReplWindow

        internal static IVsInteractiveWindow/*!*/ EnsureReplWindow(IServiceProvider serviceProvider, IPythonInterpreterFactory factory, PythonProjectNode project) {
            var compModel = serviceProvider.GetComponentModel();
            var provider = compModel.GetService<InteractiveWindowProvider>();

            string replId = PythonReplEvaluatorProvider.GetReplId(factory, project);
            var window = provider.FindReplWindow(replId);
            if (window == null) {
                window = provider.CreateInteractiveWindow(
                    serviceProvider.GetPythonContentType(),
                    factory.Description + " Interactive",
                    typeof(PythonLanguageInfo).GUID,
                    replId
                );

                var toolWindow = window as ToolWindowPane;
                if (toolWindow != null) {
                    toolWindow.BitmapImageMoniker = KnownMonikers.PYInteractiveWindow;
                }

                var pyService = serviceProvider.GetPythonToolsService();
                window.InteractiveWindow.SetSmartUpDown(pyService.GetInteractiveOptions(factory).ReplSmartHistory);
            }

            if (project != null && project.Interpreters.IsProjectSpecific(factory)) {
                project.AddActionOnClose(window, BasePythonReplEvaluator.CloseReplWindow);
            }

            return window;
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:29,代码来源:ExecuteInReplCommand.cs

示例2: OnCreate

        protected override void OnCreate() {
            base.OnCreate();

            _site = (IServiceProvider)this;

            _pyService = _site.GetPythonToolsService();

#if DEV14_OR_LATER
            // TODO: Get PYEnvironment added to image list
            BitmapImageMoniker = KnownMonikers.DockPanel;
#else
            BitmapResourceID = PythonConstants.ResourceIdForReplImages;
            BitmapIndex = 0;
#endif
            Caption = SR.GetString(SR.Environments);

            _service = _site.GetComponentModel().GetService<IInterpreterOptionsService>();
            
            _outputWindow = OutputWindowRedirector.GetGeneral(_site);
            Debug.Assert(_outputWindow != null);
            _statusBar = _site.GetService(typeof(SVsStatusbar)) as IVsStatusbar;
            
            var list = new ToolWindow();
            list.ViewCreated += List_ViewCreated;

            list.CommandBindings.Add(new CommandBinding(
                EnvironmentView.OpenInteractiveWindow,
                OpenInteractiveWindow_Executed,
                OpenInteractiveWindow_CanExecute
            ));
            list.CommandBindings.Add(new CommandBinding(
                EnvironmentView.OpenInteractiveOptions,
                OpenInteractiveOptions_Executed,
                OpenInteractiveOptions_CanExecute
            ));
            list.CommandBindings.Add(new CommandBinding(
                EnvironmentPathsExtension.StartInterpreter,
                StartInterpreter_Executed,
                StartInterpreter_CanExecute
            ));
            list.CommandBindings.Add(new CommandBinding(
                EnvironmentPathsExtension.StartWindowsInterpreter,
                StartInterpreter_Executed,
                StartInterpreter_CanExecute
            ));
            list.CommandBindings.Add(new CommandBinding(
                ApplicationCommands.Help,
                OnlineHelp_Executed,
                OnlineHelp_CanExecute
            ));
            list.CommandBindings.Add(new CommandBinding(
                ToolWindow.UnhandledException,
                UnhandledException_Executed,
                UnhandledException_CanExecute
            ));

            list.Service = _service;

            Content = list;
        }
开发者ID:munyirik,项目名称:PTVS,代码行数:60,代码来源:InterpreterListToolWindow.cs

示例3: StandaloneTargetView

        public StandaloneTargetView(IServiceProvider serviceProvider) {
            var componentService = serviceProvider.GetComponentModel();
            
            var interpreterProviders = componentService.DefaultExportProvider.GetExports<IPythonInterpreterFactoryProvider, Dictionary<string, object>>();
            var interpreterOptions = componentService.GetService<IInterpreterOptionsService>();
            var registry = componentService.GetService<IInterpreterRegistryService>();
            var pythonService = serviceProvider.GetPythonToolsService();

            var availableInterpreters = registry.Configurations.Select(
                config => new PythonInterpreterView(
                    config.Description, 
                    config.Id, 
                    config.InterpreterPath
                )
            ).ToList();

            _customInterpreter = new PythonInterpreterView("Other...", "", null);
            availableInterpreters.Add(_customInterpreter);
            _availableInterpreters = new ReadOnlyCollection<PythonInterpreterView>(availableInterpreters);

            _interpreterPath = null;
            _canSpecifyInterpreterPath = false;
            _scriptPath = null;
            _workingDirectory = null;
            _arguments = null;

            _isValid = false;

            PropertyChanged += new PropertyChangedEventHandler(StandaloneTargetView_PropertyChanged);

            if (IsAnyAvailableInterpreters) {
                var defaultId = interpreterOptions.DefaultInterpreterId;
                Interpreter = AvailableInterpreters.FirstOrDefault(v => v.Id == defaultId);
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:35,代码来源:StandaloneTargetView.cs

示例4: PythonReplEvaluator

 public PythonReplEvaluator(IPythonInterpreterFactory interpreter, IServiceProvider serviceProvider, PythonReplEvaluatorOptions options, IInterpreterOptionsService interpreterService = null)
     : base(serviceProvider, serviceProvider.GetPythonToolsService(), options) {
     _interpreter = interpreter;
     _interpreterService = interpreterService;
     if (_interpreterService != null) {
         _interpreterService.InterpretersChanged += InterpretersChanged;
     }
 }
开发者ID:smallwave,项目名称:PTVS,代码行数:8,代码来源:PythonReplEvaluator.cs

示例5: ContinueCreate

        private static async Task ContinueCreate(IServiceProvider provider, IPythonInterpreterFactory factory, string path, bool useVEnv, Redirector output) {
            path = CommonUtils.TrimEndSeparator(path);
            var name = Path.GetFileName(path);
            var dir = Path.GetDirectoryName(path);

            if (output != null) {
                output.WriteLine(SR.GetString(SR.VirtualEnvCreating, path));
                if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForVirtualEnvCreate) {
                    output.ShowAndActivate();
                } else {
                    output.Show();
                }
            }

            // Ensure the target directory exists.
            Directory.CreateDirectory(dir);

            using (var proc = ProcessOutput.Run(
                factory.Configuration.InterpreterPath,
                new[] { "-m", useVEnv ? "venv" : "virtualenv", name },
                dir,
                UnbufferedEnv,
                false,
                output
            )) {
                var exitCode = await proc;

                if (output != null) {
                    if (exitCode == 0) {
                        output.WriteLine(SR.GetString(SR.VirtualEnvCreationSucceeded, path));
                    } else {
                        output.WriteLine(SR.GetString(SR.VirtualEnvCreationFailedExitCode, path, exitCode));
                    }
                    if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForVirtualEnvCreate) {
                        output.ShowAndActivate();
                    } else {
                        output.Show();
                    }
                }

                if (exitCode != 0 || !Directory.Exists(path)) {
                    throw new InvalidOperationException(SR.GetString(SR.VirtualEnvCreationFailed, path));
                }
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:45,代码来源:VirtualEnv.cs

示例6: UnresolvedImportSquiggleProvider

 public UnresolvedImportSquiggleProvider(IServiceProvider serviceProvider, TaskProvider taskProvider) {
     _serviceProvider = serviceProvider;
     _taskProvider = taskProvider;
     var options = _serviceProvider.GetPythonToolsService()?.GeneralOptions;
     if (options != null) {
         _enabled = options.UnresolvedImportWarning;
         options.Changed += GeneralOptions_Changed;
     }
 }
开发者ID:ygjftd,项目名称:PTVS,代码行数:9,代码来源:UnresolvedImportSquiggleProvider.cs

示例7: PythonWebLauncher

 public PythonWebLauncher(
     IServiceProvider serviceProvider,
     LaunchConfiguration runConfig,
     LaunchConfiguration debugConfig,
     LaunchConfiguration defaultConfig
 ) {
     _serviceProvider = serviceProvider;
     _pyService = _serviceProvider.GetPythonToolsService();
     _runConfig = runConfig;
     _debugConfig = debugConfig;
     _defaultConfig = defaultConfig;
 }
开发者ID:zooba,项目名称:PTVS,代码行数:12,代码来源:PythonWebLauncher.cs

示例8: Install

 /// <summary>
 /// Installs virtualenv. If pip is not installed, the returned task will
 /// succeed but error text will be passed to the redirector.
 /// </summary>
 public static Task<bool> Install(IServiceProvider provider, IPythonInterpreterFactory factory, Redirector output = null) {
     bool elevate = provider.GetPythonToolsService().GeneralOptions.ElevatePip;
     if (factory.Configuration.Version < new Version(2, 5)) {
         if (output != null) {
             output.WriteErrorLine("Python versions earlier than 2.5 are not supported by PTVS.");
         }
         throw new OperationCanceledException();
     } else if (factory.Configuration.Version == new Version(2, 5)) {
         return Pip.Install(provider, factory, "https://go.microsoft.com/fwlink/?LinkID=317970", elevate, output);
     } else {
         return Pip.Install(provider, factory, "https://go.microsoft.com/fwlink/?LinkID=317969", elevate, output);
     }
 }
开发者ID:wenh123,项目名称:PTVS,代码行数:17,代码来源:VirtualEnv.cs

示例9: PythonDebugReplEvaluator

        public PythonDebugReplEvaluator(IServiceProvider serviceProvider) {
            _serviceProvider = serviceProvider;
            _pyService = serviceProvider.GetPythonToolsService();
            AD7Engine.EngineAttached += new EventHandler<AD7EngineEventArgs>(OnEngineAttached);
            AD7Engine.EngineDetaching += new EventHandler<AD7EngineEventArgs>(OnEngineDetaching);

            var dte = _serviceProvider.GetDTE();
            if (dte != null) {
                // running outside of VS, make this work for tests.
                _debuggerEvents = dte.Events.DebuggerEvents;
                _debuggerEvents.OnEnterBreakMode += new EnvDTE._dispDebuggerEvents_OnEnterBreakModeEventHandler(OnEnterBreakMode);
            }
        }
开发者ID:rotorliu,项目名称:PTVS,代码行数:13,代码来源:PythonDebugReplEvaluator.cs

示例10: EnsureReplWindow

        internal static IVsInteractiveWindow/*!*/ EnsureReplWindow(IServiceProvider serviceProvider) {
            var compModel = serviceProvider.GetComponentModel();
            var provider = compModel.GetService<InteractiveWindowProvider>();

            string replId = PythonDebugReplEvaluatorProvider.GetDebugReplId();
            var window = provider.FindReplWindow(replId);
            if (window == null) {
                window = provider.CreateInteractiveWindow(serviceProvider.GetPythonContentType(), "Python Debug Interactive", typeof(PythonLanguageInfo).GUID, replId);

                var pyService = serviceProvider.GetPythonToolsService();
                window.InteractiveWindow.SetSmartUpDown(pyService.DebugInteractiveOptions.ReplSmartHistory);
            }
            return window;
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:14,代码来源:OpenDebugReplCommand.cs

示例11: GetOptions

        public static CompletionOptions GetOptions(this ICompletionSession session, IServiceProvider serviceProvider) {
            var pyService = serviceProvider.GetPythonToolsService();

            var options = new CompletionOptions {
                ConvertTabsToSpaces = session.TextView.Options.IsConvertTabsToSpacesEnabled(),
                IndentSize = session.TextView.Options.GetIndentSize(),
                TabSize = session.TextView.Options.GetTabSize()
            };

            options.IntersectMembers = pyService.AdvancedOptions.IntersectMembers;
            options.HideAdvancedMembers = pyService.LangPrefs.HideAdvancedMembers;
            options.FilterCompletions = pyService.AdvancedOptions.FilterCompletions;
            options.SearchMode = pyService.AdvancedOptions.SearchMode;
            return options;
        }
开发者ID:RussBaz,项目名称:PTVS,代码行数:15,代码来源:CompletionSource.cs

示例12: ShouldElevate

        public static bool ShouldElevate(IServiceProvider site, InterpreterConfiguration config, string operation) {
            var opts = site.GetPythonToolsService().GeneralOptions;
            if (opts.ElevatePip) {
                return true;
            }

            try {
                // Create a test file and delete it immediately to ensure we can do it.
                // If this fails, prompt the user to see whether they want to elevate.
                var testFile = PathUtils.GetAvailableFilename(config.PrefixPath, "access-test", ".txt");
                using (new FileStream(testFile, FileMode.CreateNew, FileAccess.Write, FileShare.Delete, 4096, FileOptions.DeleteOnClose)) { }
                return false;
            } catch (IOException) {
            } catch (UnauthorizedAccessException) {
            }

            var td = new TaskDialog(site) {
                Title = Strings.ProductTitle,
                MainInstruction = Strings.ElevateForInstallPackage_MainInstruction,
                AllowCancellation = true,
            };
            var elevate = new TaskDialogButton(Strings.ElevateForInstallPackage_Elevate, Strings.ElevateForInstallPackage_Elevate_Note) {
                ElevationRequired = true
            };
            var noElevate = new TaskDialogButton(Strings.ElevateForInstallPackage_DoNotElevate, Strings.ElevateForInstallPackage_DoNotElevate_Note);
            var elevateAlways = new TaskDialogButton(Strings.ElevateForInstallPackage_ElevateAlways, Strings.ElevateForInstallPackage_ElevateAlways_Note) {
                ElevationRequired = true
            };
            td.Buttons.Add(elevate);
            td.Buttons.Add(noElevate);
            td.Buttons.Add(elevateAlways);
            td.Buttons.Add(TaskDialogButton.Cancel);
            var sel = td.ShowModal();
            if (sel == TaskDialogButton.Cancel) {
                throw new OperationCanceledException();
            }

            if (sel == noElevate) {
                return false;
            }

            if (sel == elevateAlways) {
                opts.ElevatePip = true;
                opts.Save();
            }

            return true;
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:48,代码来源:VsPackageManagerUI.cs

示例13: PythonAutomation

 internal PythonAutomation(IServiceProvider serviceProvider) {
     _serviceProvider = serviceProvider;
     _pyService = serviceProvider.GetPythonToolsService();
     Debug.Assert(_pyService != null, "Did not find PythonToolsService");
 }
开发者ID:omnimark,项目名称:PTVS,代码行数:5,代码来源:PythonAutomation.cs

示例14: AddSearchPaths

        internal static void AddSearchPaths(
            Dictionary<string, string> env,
            IPythonProject project,
            IServiceProvider provider = null
        ) {
            var pathEnv = project.GetProjectAnalyzer().InterpreterFactory.Configuration.PathEnvironmentVariable;
            if (string.IsNullOrEmpty(pathEnv)) {
                return;
            }

            var paths = new List<string>();
            
            string path;
            if (env.TryGetValue(pathEnv, out path)) {
                paths.AddRange(path.Split(Path.PathSeparator));
            }

            paths.AddRange(EnumerateSearchPaths(project));

            if (provider != null && !provider.GetPythonToolsService().GeneralOptions.ClearGlobalPythonPath) {
                paths.AddRange((Environment.GetEnvironmentVariable(pathEnv) ?? "")
                    .Split(Path.PathSeparator)
                    .Where(p => !paths.Contains(p))
                    .ToList());
            }

            env[pathEnv] = string.Join(
                Path.PathSeparator.ToString(),
                paths
            );
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:31,代码来源:PythonProjectLaunchProperties.cs

示例15: Install

        public static async Task<bool> Install(
            IServiceProvider provider,
            IPythonInterpreterFactory factory,
            IInterpreterOptionsService service,
            string package,
            Redirector output = null
        ) {
            factory.ThrowIfNotRunnable("factory");

            var condaFactory = await TryGetCondaFactoryAsync(factory, service); ;
            if (condaFactory == null) {
                throw new InvalidOperationException("Cannot find conda");
            }
            condaFactory.ThrowIfNotRunnable();

            if (output != null) {
                output.WriteLine(SR.GetString(SR.PackageInstalling, package));
                if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForPackageInstallation) {
                    output.ShowAndActivate();
                } else {
                    output.Show();
                }
            }

            using (var proc = ProcessOutput.Run(
                condaFactory.Configuration.InterpreterPath,
                new[] { "-m", "conda", "install", "--yes", "-n", factory.Configuration.PrefixPath, package },
                factory.Configuration.PrefixPath,
                UnbufferedEnv,
                false,
                output
            )) {
                var exitCode = await proc;
                if (output != null) {
                    if (exitCode == 0) {
                        output.WriteLine(SR.GetString(SR.PackageInstallSucceeded, package));
                    } else {
                        output.WriteLine(SR.GetString(SR.PackageInstallFailedExitCode, package, exitCode));
                    }
                    if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForPackageInstallation) {
                        output.ShowAndActivate();
                    } else {
                        output.Show();
                    }
                }
                return exitCode == 0;
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:48,代码来源:Conda.cs


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