// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; namespace Microsoft.AspNetCore.Razor.Language { public abstract class RazorParserOptions { public static RazorParserOptions CreateDefault() { return new DefaultRazorParserOptions( Array.Empty(), designTime: false, parseLeadingDirectives: false, version: RazorLanguageVersion.Latest); } public static RazorParserOptions Create(Action configure) { if (configure == null) { throw new ArgumentNullException(nameof(configure)); } var builder = new DefaultRazorParserOptionsBuilder(designTime: false, version: RazorLanguageVersion.Latest); configure(builder); var options = builder.Build(); return options; } public static RazorParserOptions CreateDesignTime(Action configure) { if (configure == null) { throw new ArgumentNullException(nameof(configure)); } var builder = new DefaultRazorParserOptionsBuilder(designTime: true, version: RazorLanguageVersion.Latest); configure(builder); var options = builder.Build(); return options; } public abstract bool DesignTime { get; } public abstract IReadOnlyCollection Directives { get; } /// /// Gets a value which indicates whether the parser will parse only the leading directives. If true /// the parser will halt at the first HTML content or C# code block. If false the whole document is parsed. /// /// /// Currently setting this option to true will result in only the first line of directives being parsed. /// In a future release this may be updated to include all leading directive content. /// public abstract bool ParseLeadingDirectives { get; } public virtual RazorLanguageVersion Version { get; } = RazorLanguageVersion.Latest; internal virtual RazorParserFeatureFlags FeatureFlags { get; } } }