Beispiel #1
0
        // Internal for testing
        internal static bool TryGetConfiguration(
            IImmutableDictionary <string, IProjectRuleSnapshot> state,
            out RazorConfiguration configuration)
        {
            if (!TryGetDefaultConfiguration(state, out var defaultConfiguration))
            {
                configuration = null;
                return(false);
            }

            if (!TryGetLanguageVersion(state, out var languageVersion))
            {
                configuration = null;
                return(false);
            }

            if (!TryGetConfigurationItem(defaultConfiguration, state, out var configurationItem))
            {
                configuration = null;
                return(false);
            }

            var extensionNames = GetExtensionNames(configurationItem);

            if (!TryGetExtensions(extensionNames, state, out var extensions))
            {
                configuration = null;
                return(false);
            }

            configuration = new ProjectSystemRazorConfiguration(languageVersion, configurationItem.Key, extensions);
            return(true);
        }
        // Internal for testing
        internal static bool TryGetConfiguration(
            ProjectState projectState,
            out RazorConfiguration configuration)
        {
            if (!TryGetDefaultConfiguration(projectState, out var defaultConfiguration))
            {
                configuration = null;
                return(false);
            }

            if (!TryGetLanguageVersion(projectState, out var languageVersion))
            {
                configuration = null;
                return(false);
            }

            if (!TryGetConfigurationItem(defaultConfiguration, projectState, out var configurationItem))
            {
                configuration = null;
                return(false);
            }

            if (!TryGetConfiguredExtensionNames(configurationItem, out var configuredExtensionNames))
            {
                configuration = null;
                return(false);
            }

            if (!TryGetExtensions(configuredExtensionNames, projectState, out var extensions))
            {
                configuration = null;
                return(false);
            }

            configuration = new ProjectSystemRazorConfiguration(languageVersion, configurationItem.Key, extensions);
            return(true);
        }