Пример #1
0
        public void Load()
        {
            var changed         = false;
            var autoSearchPaths = _service.LoadBool(nameof(AutoSearchPaths), Category) ?? true;

            if (AutoSearchPaths != autoSearchPaths)
            {
                AutoSearchPaths = autoSearchPaths;
                changed         = true;
            }

            var diagnosticMode = _service.LoadString(nameof(DiagnosticMode), Category) ?? PylanceDiagnosticMode.OpenFilesOnly;

            if (DiagnosticMode != diagnosticMode)
            {
                DiagnosticMode = diagnosticMode;
                changed        = true;
            }

            var logLevel = _service.LoadString(nameof(LogLevel), Category) ?? PylanceLogLevel.Information;

            if (LogLevel != logLevel)
            {
                LogLevel = logLevel;
                changed  = true;
            }

            var stubPath = _service.LoadString(nameof(StubPath), Category);

            if (StubPath != stubPath)
            {
                StubPath = stubPath;
                changed  = true;
            }

            var typeCheckingMode = _service.LoadString(nameof(TypeCheckingMode), Category) ?? PylanceTypeCheckingMode.Off;

            if (TypeCheckingMode != typeCheckingMode)
            {
                TypeCheckingMode = typeCheckingMode;
                changed          = true;
            }

            var typeshedPaths = _service.LoadMultilineString(nameof(TypeshedPaths), Category);

            if (!Enumerable.SequenceEqual(TypeshedPaths.MaybeEnumerate(), typeshedPaths.MaybeEnumerate()))
            {
                TypeshedPaths = typeshedPaths;
                changed       = true;
            }

            var extraPaths = _service.LoadMultilineString(nameof(ExtraPaths), Category);

            if (!Enumerable.SequenceEqual(ExtraPaths.MaybeEnumerate(), extraPaths.MaybeEnumerate()))
            {
                ExtraPaths = extraPaths;
                changed    = true;
            }

            var useLibraryCodeForTypes = _service.LoadBool(nameof(UseLibraryCodeForTypes), Category) ?? true;

            if (UseLibraryCodeForTypes != useLibraryCodeForTypes)
            {
                UseLibraryCodeForTypes = useLibraryCodeForTypes;
                changed = true;
            }

            if (changed)
            {
                Changed?.Invoke(this, EventArgs.Empty);
            }
        }