Exemple #1
0
        internal EnvironmentView(
            IInterpreterOptionsService service,
            IInterpreterRegistryService registry,
            IPythonInterpreterFactory factory,
            Redirector redirector
            )
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            if (factory.Configuration == null)
            {
                throw new ArgumentException("factory must include a configuration");
            }

            _service                 = service;
            _registry                = registry;
            Factory                  = factory;
            Configuration            = Factory.Configuration;
            LocalizedDisplayName     = Configuration.Description;
            IsBroken                 = !Configuration.IsRunnable();
            LocalizedAutomationName  = !IsBroken ? LocalizedDisplayName : String.Format(Resources.BrokenEnvironmentAutomationNameFormat, LocalizedDisplayName);
            BrokenEnvironmentHelpUrl = "https://go.microsoft.com/fwlink/?linkid=863373";

            if (_service.IsConfigurable(Factory.Configuration.Id))
            {
                IsConfigurable = true;
            }

            Description = Factory.Configuration.Description;
            IsDefault   = (_service != null && _service.DefaultInterpreterId == Configuration.Id);

            PrefixPath             = Factory.Configuration.GetPrefixPath();
            InterpreterPath        = Factory.Configuration.InterpreterPath;
            WindowsInterpreterPath = Factory.Configuration.GetWindowsInterpreterPath();

            Extensions = new ObservableCollection <object>();
            Extensions.Add(new EnvironmentPathsExtensionProvider());
            if (IsConfigurable)
            {
                Extensions.Add(new ConfigurationExtensionProvider(_service, alwaysCreateNew: false));
            }

            CanBeDefault = Factory.CanBeDefault();
            CanBeDeleted = Factory.CanBeDeleted();

            Company    = _registry.GetProperty(Factory.Configuration.Id, CompanyKey) as string ?? "";
            SupportUrl = _registry.GetProperty(Factory.Configuration.Id, SupportUrlKey) as string ?? "";

            LocalizedHelpText = Company;
        }
Exemple #2
0
        internal EnvironmentView(
            IInterpreterOptionsService service,
            IInterpreterRegistryService registry,
            IPythonInterpreterFactory factory,
            Redirector redirector
            )
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            _service  = service;
            _registry = registry;
            Factory   = factory;

            _withDb = factory as IPythonInterpreterFactoryWithDatabase;
            if (_withDb != null)
            {
                _withDb.IsCurrentChanged += Factory_IsCurrentChanged;
                IsCheckingDatabase        = _withDb.IsCheckingDatabase;
                IsCurrent = _withDb.IsCurrent;
            }


            if (_service.IsConfigurable(factory.Configuration.Id))
            {
                IsConfigurable = true;
            }

            Description = Factory.Configuration.Description;
            IsDefault   = (_service != null && _service.DefaultInterpreter == Factory);

            PrefixPath             = Factory.Configuration.PrefixPath;
            InterpreterPath        = Factory.Configuration.InterpreterPath;
            WindowsInterpreterPath = Factory.Configuration.WindowsInterpreterPath;

            Extensions = new ObservableCollection <object>();
            Extensions.Add(new EnvironmentPathsExtensionProvider());
            if (IsConfigurable)
            {
                Extensions.Add(new ConfigurationExtensionProvider(_service));
            }

            CanBeDefault = Factory.CanBeDefault();

            Company    = _registry.GetProperty(Factory.Configuration.Id, CompanyKey) as string ?? "";
            SupportUrl = _registry.GetProperty(Factory.Configuration.Id, SupportUrlKey) as string ?? "";
        }
Exemple #3
0
        internal EnvironmentView(
            IInterpreterOptionsService service,
            IPythonInterpreterFactory factory,
            Redirector redirector
            )
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }

            _service = service;
            Factory  = factory;

            _withDb = factory as IPythonInterpreterFactoryWithDatabase;
            if (_withDb != null)
            {
                _withDb.IsCurrentChanged += Factory_IsCurrentChanged;
                IsCheckingDatabase        = _withDb.IsCheckingDatabase;
                IsCurrent = _withDb.IsCurrent;
            }

            var configurableProvider = _service != null?
                                       _service.KnownProviders
                                       .OfType <ConfigurablePythonInterpreterFactoryProvider>()
                                       .FirstOrDefault() :
                                           null;

            if (configurableProvider != null && configurableProvider.IsConfigurable(factory))
            {
                IsConfigurable = true;
            }

            Description = Factory.Description;
            IsDefault   = (_service != null && _service.DefaultInterpreter == Factory);

            PrefixPath             = Factory.Configuration.PrefixPath;
            InterpreterPath        = Factory.Configuration.InterpreterPath;
            WindowsInterpreterPath = Factory.Configuration.WindowsInterpreterPath;
            LibraryPath            = Factory.Configuration.LibraryPath;

            Extensions = new ObservableCollection <object>();
            Extensions.Add(new EnvironmentPathsExtensionProvider());
            if (IsConfigurable)
            {
                Extensions.Add(new ConfigurationExtensionProvider(configurableProvider));
            }

            CanBeDefault = Factory.CanBeDefault();
        }
Exemple #4
0
        internal EnvironmentView(
            IInterpreterOptionsService service,
            IInterpreterRegistryService registry,
            IPythonInterpreterFactory factory,
            Redirector redirector
        ) {
            if (service == null) {
                throw new ArgumentNullException(nameof(service));
            }
            if (registry == null) {
                throw new ArgumentNullException(nameof(registry));
            }
            if (factory == null) {
                throw new ArgumentNullException(nameof(factory));
            }
            if (factory.Configuration == null) {
                throw new ArgumentException("factory must include a configuration");
            }

            _service = service;
            _registry = registry;
            Factory = factory;
            Configuration = Factory.Configuration;

            _withDb = factory as IPythonInterpreterFactoryWithDatabase;
            if (_withDb != null) {
                _withDb.IsCurrentChanged += Factory_IsCurrentChanged;
                IsCheckingDatabase = _withDb.IsCheckingDatabase;
                IsCurrent = _withDb.IsCurrent;
            }
            

            if (_service.IsConfigurable(Factory.Configuration.Id)) {
                IsConfigurable = true;
            }

            Description = Factory.Configuration.Description;
            IsDefault = (_service != null && _service.DefaultInterpreterId == Configuration.Id);

            PrefixPath = Factory.Configuration.PrefixPath;
            InterpreterPath = Factory.Configuration.InterpreterPath;
            WindowsInterpreterPath = Factory.Configuration.WindowsInterpreterPath;

            Extensions = new ObservableCollection<object>();
            Extensions.Add(new EnvironmentPathsExtensionProvider());
            if (IsConfigurable) {
                Extensions.Add(new ConfigurationExtensionProvider(_service, alwaysCreateNew: false));
            }

            CanBeDefault = Factory.CanBeDefault();

            Company = _registry.GetProperty(Factory.Configuration.Id, CompanyKey) as string ?? "";
            SupportUrl = _registry.GetProperty(Factory.Configuration.Id, SupportUrlKey) as string ?? "";
        }
Exemple #5
0
        internal EnvironmentView(
            IInterpreterOptionsService service,
            IPythonInterpreterFactory factory,
            Redirector redirector
        ) {
            if (service == null) {
                throw new ArgumentNullException("service");
            }
            if (factory == null) {
                throw new ArgumentNullException("factory");
            }

            _service = service;
            Factory = factory;

            _withDb = factory as IPythonInterpreterFactoryWithDatabase;
            if (_withDb != null) {
                _withDb.IsCurrentChanged += Factory_IsCurrentChanged;
                IsCheckingDatabase = _withDb.IsCheckingDatabase;
                IsCurrent = _withDb.IsCurrent;
            }

            var configurableProvider = _service != null ?
                _service.KnownProviders
                    .OfType<ConfigurablePythonInterpreterFactoryProvider>()
                    .FirstOrDefault() :
                null;

            if (configurableProvider != null && configurableProvider.IsConfigurable(factory)) {
                IsConfigurable = true;
            }

            Description = Factory.Description;
            IsDefault = (_service != null && _service.DefaultInterpreter == Factory);

            PrefixPath = Factory.Configuration.PrefixPath;
            InterpreterPath = Factory.Configuration.InterpreterPath;
            WindowsInterpreterPath = Factory.Configuration.WindowsInterpreterPath;
            LibraryPath = Factory.Configuration.LibraryPath;

            Extensions = new ObservableCollection<object>();
            Extensions.Add(new EnvironmentPathsExtensionProvider());
            if (IsConfigurable) {
                Extensions.Add(new ConfigurationExtensionProvider(configurableProvider));
            }

            CanBeDefault = Factory.CanBeDefault();
        }
Exemple #6
0
        internal EnvironmentView(
            IInterpreterOptionsService service,
            IInterpreterRegistryService registry,
            IPythonInterpreterFactory factory,
            Redirector redirector
            )
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            if (factory.Configuration == null)
            {
                throw new ArgumentException("factory must include a configuration");
            }

            _service                 = service;
            _registry                = registry;
            Factory                  = factory;
            Configuration            = Factory.Configuration;
            LocalizedDisplayName     = Configuration.Description;
            IsBroken                 = !Configuration.IsRunnable();
            BrokenEnvironmentHelpUrl = "https://go.microsoft.com/fwlink/?linkid=863373";

            var withDb = factory as Interpreter.LegacyDB.IPythonInterpreterFactoryWithDatabase;

            if (withDb != null)
            {
                withDb.IsCurrentChanged += Factory_IsCurrentChanged;
                IsCheckingDatabase       = withDb.IsCheckingDatabase;
                IsCurrent = withDb.IsCurrent;
            }


            if (_service.IsConfigurable(Factory.Configuration.Id))
            {
                IsConfigurable = true;
            }

            Description = Factory.Configuration.Description;
            IsDefault   = (_service != null && _service.DefaultInterpreterId == Configuration.Id);

            PrefixPath             = Factory.Configuration.PrefixPath;
            InterpreterPath        = Factory.Configuration.InterpreterPath;
            WindowsInterpreterPath = Factory.Configuration.WindowsInterpreterPath;

            Extensions = new ObservableCollection <object>();
            Extensions.Add(new EnvironmentPathsExtensionProvider());
            if (IsConfigurable)
            {
                Extensions.Add(new ConfigurationExtensionProvider(_service, alwaysCreateNew: false));
            }

            CanBeDefault = Factory.CanBeDefault();

            Company    = _registry.GetProperty(Factory.Configuration.Id, CompanyKey) as string ?? "";
            SupportUrl = _registry.GetProperty(Factory.Configuration.Id, SupportUrlKey) as string ?? "";

            LocalizedHelpText = Company;
        }
Exemple #7
0
        internal EnvironmentView(
            IInterpreterOptionsService service,
            IInterpreterRegistryService registry,
            IPythonInterpreterFactory factory,
            Redirector redirector
            )
        {
            if (service == null) {
                throw new ArgumentNullException(nameof(service));
            }
            if (registry == null) {
                throw new ArgumentNullException(nameof(registry));
            }
            if (factory == null) {
                throw new ArgumentNullException(nameof(factory));
            }

            _service = service;
            _registry = registry;
            Factory = factory;

            _withDb = factory as IPythonInterpreterFactoryWithDatabase;
            if (_withDb != null) {
                _withDb.IsCurrentChanged += Factory_IsCurrentChanged;
                IsCheckingDatabase = _withDb.IsCheckingDatabase;
                IsCurrent = _withDb.IsCurrent;
            }

            if (_service.IsConfigurable(factory.Configuration.Id)) {
                IsConfigurable = true;
            }

            Description = Factory.Configuration.FullDescription;
            IsDefault = (_service != null && _service.DefaultInterpreter == Factory);

            PrefixPath = Factory.Configuration.PrefixPath;
            InterpreterPath = Factory.Configuration.InterpreterPath;
            WindowsInterpreterPath = Factory.Configuration.WindowsInterpreterPath;
            LibraryPath = Factory.Configuration.LibraryPath;

            Extensions = new ObservableCollection<object>();
            Extensions.Add(new EnvironmentPathsExtensionProvider());
            if (IsConfigurable) {
                Extensions.Add(new ConfigurationExtensionProvider(_service));
            }

            CanBeDefault = Factory.CanBeDefault();

            Vendor = _registry.GetProperty(Factory.Configuration.Id, "Vendor") as string;
            SupportUrl = _registry.GetProperty(Factory.Configuration.Id, "SupportUrl") as string;
        }