コード例 #1
0
ファイル: PythonWorkspaceContext.cs プロジェクト: int19h/PTVS
        public PythonWorkspaceContext(
            IWorkspace workspace,
            IPropertyEvaluatorService workspacePropertyEvaluator,
            IInterpreterOptionsService optionsService,
            IInterpreterRegistryService registryService)
        {
            _workspace                = workspace ?? throw new ArgumentNullException(nameof(workspace));
            _optionsService           = optionsService ?? throw new ArgumentNullException(nameof(optionsService));
            _registryService          = registryService ?? throw new ArgumentNullException(nameof(registryService));
            _workspaceSettingsMgr     = _workspace.GetSettingsManager();
            _propertyEvaluatorService = workspacePropertyEvaluator;


            // Initialization in 2 phases (Constructor + Initialize) is needed to
            // break a circular dependency.
            // We create a partially initialized object that can be used by
            // WorkspaceInterpreterFactoryProvider to discover the interpreters
            // in this workspace (it needs the interpreter setting to do that).
            // Once that is done, the IPythonInterpreterFactory on this object
            // can be resolved in Initialize.
            _interpreter           = ReadInterpreterSetting();
            _searchPaths           = ReadSearchPathsSetting();
            _testFramework         = GetStringProperty(TestFrameworkProperty);
            _unitTestRootDirectory = GetStringProperty(UnitTestRootDirectoryProperty);
            _unitTestPattern       = GetStringProperty(UnitTestPatternProperty);
        }
コード例 #2
0
 public EnvironmentSwitcherWorkspaceContext(IServiceProvider serviceProvider, IWorkspace workspace)
 {
     _serviceProvider      = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
     _optionsService       = serviceProvider.GetComponentModel().GetService <IInterpreterOptionsService>();
     _registryService      = serviceProvider.GetComponentModel().GetService <IInterpreterRegistryService>();
     _workspace            = workspace ?? throw new ArgumentNullException(nameof(workspace));
     _workspaceSettingsMgr = _workspace.GetSettingsManager();
     _workspaceSettingsMgr.OnWorkspaceSettingsChanged += OnSettingsChanged;
 }
コード例 #3
0
 public PythonWorkspaceContext(
     IWorkspace workspace,
     IInterpreterOptionsService optionsService,
     IInterpreterRegistryService registryService)
 {
     _workspace            = workspace ?? throw new ArgumentNullException(nameof(workspace));
     _optionsService       = optionsService ?? throw new ArgumentNullException(nameof(optionsService));
     _registryService      = registryService ?? throw new ArgumentNullException(nameof(registryService));
     _workspaceSettingsMgr = _workspace.GetSettingsManager();
 }
コード例 #4
0
        private void InitializeWorkspace()
        {
            lock (_factories) {
                // Cleanup state associated with the previous workspace, if any
                if (_workspaceSettingsMgr != null)
                {
                    _workspaceSettingsMgr.OnWorkspaceSettingsChanged -= OnSettingsChanged;
                }

                _folderWatcher?.Dispose();
                _folderWatcher = null;
                _folderWatcherTimer?.Dispose();
                _folderWatcherTimer = null;

                // Setup new workspace
                _workspace            = _workspaceService.CurrentWorkspace;
                _workspaceSettingsMgr = _workspace?.GetSettingsManager();
                if (_workspaceSettingsMgr != null)
                {
                    _workspaceSettingsMgr.OnWorkspaceSettingsChanged += OnSettingsChanged;
                }

                if (_workspace != null)
                {
                    try {
                        _folderWatcher                       = new FileSystemWatcher(_workspace.Location, "*.*");
                        _folderWatcher.Created              += OnFileCreatedDeletedRenamed;
                        _folderWatcher.Deleted              += OnFileCreatedDeletedRenamed;
                        _folderWatcher.Renamed              += OnFileCreatedDeletedRenamed;
                        _folderWatcher.EnableRaisingEvents   = true;
                        _folderWatcher.IncludeSubdirectories = true;
                    } catch (ArgumentException) {
                    } catch (IOException) {
                    }
                    _folderWatcherTimer = new Timer(OnFileChangesTimerElapsed);
                }
            }
        }