Beispiel #1
0
        public static ExecutionMode[] GetRegisteredModes(IServiceProvider serviceProvider)
        {
            List <ExecutionMode> res = new List <ExecutionMode>();

            // ExecutionMode is structured like:
            // HKLM\Software\VisualStudio\Hive\PythonTools:
            //      ReplExecutionModes\
            //          ModeID\
            //              Type
            //              FriendlyName
            //              SupportsMultipleScopes
            //              SupportsMultipleCompleteStatementInputs
            //
            var settingsManager = PythonToolsPackage.GetSettings(serviceProvider);
            var store           = settingsManager.GetReadOnlySettingsStore(SettingsScope.Configuration);
            var itemCount       = store.GetSubCollectionCount(PythonInteractiveOptionsControl.PythonExecutionModeKey);

            foreach (string modeID in store.GetSubCollectionNames(PythonInteractiveOptionsControl.PythonExecutionModeKey))
            {
                var  value = store.GetString(PythonInteractiveOptionsControl.PythonExecutionModeKey + "\\" + modeID, "SupportsMultipleScopes", "True");
                bool multipleScopes;
                if (!Boolean.TryParse(value, out multipleScopes))
                {
                    multipleScopes = true;
                }

                value = store.GetString(PythonInteractiveOptionsControl.PythonExecutionModeKey + "\\" + modeID, "SupportsMultipleCompleteStatementInputs", "True");
                bool supportsMultipleCompleteStatementInputs;
                if (!Boolean.TryParse(value, out supportsMultipleCompleteStatementInputs))
                {
                    supportsMultipleCompleteStatementInputs = false;
                }

                var type         = store.GetString(PythonInteractiveOptionsControl.PythonExecutionModeKey + "\\" + modeID, "Type");
                var friendlyName = store.GetString(PythonInteractiveOptionsControl.PythonExecutionModeKey + "\\" + modeID, "FriendlyName");
                res.Add(
                    new ExecutionMode(
                        modeID,
                        type,
                        friendlyName,
                        multipleScopes,
                        supportsMultipleCompleteStatementInputs
                        )
                    );
            }
            res.Sort((x, y) => String.Compare(x.FriendlyName, y.FriendlyName, true));
            return(res.ToArray());
        }
Beispiel #2
0
        public PythonToolsOptionsService(IServiceProvider serviceProvider)
        {
            var settingsManager = PythonToolsPackage.GetSettings(serviceProvider);

            _settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
        }