public DefaultRazorCodeGenerationOptionsBuilder(RazorConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } }
public static RazorProjectEngine Create( RazorProjectFileSystem fileSystem, RazorConfiguration configuration, Action <RazorProjectEngineBuilder> configure) { if (fileSystem == null) { throw new ArgumentNullException(nameof(fileSystem)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var builder = new DefaultRazorProjectEngineBuilder(configuration, fileSystem); AddDefaults(builder); if (configuration.DesignTime) { AddDesignTimeDefaults(builder); } else { AddRuntimeDefaults(builder); } configure?.Invoke(builder); return(builder.Build()); }
public DefaultRazorCodeGenerationOptionsBuilder(RazorConfiguration configuration, string fileKind) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } Configuration = configuration; FileKind = fileKind; }
protected RazorProjectEngine CreateProjectEngine(Action <RazorProjectEngineBuilder> configure) { var configuration = RazorConfiguration.Create(Version, "test", Array.Empty <RazorExtension>()); return(RazorProjectEngine.Create(configuration, RazorProjectFileSystem.Empty, b => { ConfigureProjectEngine(b); configure?.Invoke(b); })); }
public DefaultRazorParserOptionsBuilder(RazorConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } Configuration = configuration; LanguageVersion = configuration.LanguageVersion; }
public DefaultRazorProjectEngineBuilder(RazorConfiguration configuration, RazorProjectFileSystem fileSystem) { if (fileSystem == null) { throw new ArgumentNullException(nameof(fileSystem)); } Configuration = configuration; FileSystem = fileSystem; Features = new List <IRazorFeature>(); Phases = new List <IRazorEnginePhase>(); }
public static RazorProjectEngine Create( RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action <RazorProjectEngineBuilder> configure) { if (fileSystem == null) { throw new ArgumentNullException(nameof(fileSystem)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var builder = new DefaultRazorProjectEngineBuilder(configuration, fileSystem); // The intialization order is somewhat important. // // Defaults -> Extensions -> Additional customization // // This allows extensions to rely on default features, and customizations to override choices made by // extensions. AddDefaultPhases(builder.Phases); AddDefaultFeatures(builder.Features); if (configuration.LanguageVersion.CompareTo(RazorLanguageVersion.Version_5_0) >= 0) { builder.Features.Add(new ViewCssScopePass()); } if (configuration.LanguageVersion.CompareTo(RazorLanguageVersion.Version_3_0) >= 0) { FunctionsDirective.Register(builder); ImplementsDirective.Register(builder); InheritsDirective.Register(builder); NamespaceDirective.Register(builder); AttributeDirective.Register(builder); AddComponentFeatures(builder, configuration.LanguageVersion); } LoadExtensions(builder, configuration.Extensions); configure?.Invoke(builder); return(builder.Build()); }
private static void AddDefaultRuntimeFeatures(RazorConfiguration configuration, ICollection <IRazorEngineFeature> features) { // Configure options features.Add(new DefaultRazorParserOptionsFeature(designTime: false, version: configuration.LanguageVersion, fileKind: null)); features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false)); // Intermediate Node Passes features.Add(new PreallocatedTagHelperAttributeOptimizationPass()); // Code Target Extensions var targetExtension = features.OfType <IRazorTargetExtensionFeature>().FirstOrDefault(); Debug.Assert(targetExtension != null); targetExtension.TargetExtensions.Add(new DefaultTagHelperTargetExtension()); targetExtension.TargetExtensions.Add(new PreallocatedAttributeTargetExtension()); }
private static void AddDefaultDesignTimeFeatures(RazorConfiguration configuration, ICollection <IRazorEngineFeature> features) { // Configure options features.Add(new DefaultRazorParserOptionsFeature(designTime: true, version: configuration.LanguageVersion, fileKind: null)); features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: true)); features.Add(new SuppressChecksumOptionsFeature()); // Intermediate Node Passes features.Add(new DesignTimeDirectivePass()); // Code Target Extensions var targetExtension = features.OfType <IRazorTargetExtensionFeature>().FirstOrDefault(); Debug.Assert(targetExtension != null); targetExtension.TargetExtensions.Add(new DefaultTagHelperTargetExtension()); targetExtension.TargetExtensions.Add(new DesignTimeDirectiveTargetExtension()); }
// Internal since RazorEngine APIs are going to be obsolete. internal static RazorEngine CreateCore(RazorConfiguration configuration, bool designTime, Action <IRazorEngineBuilder> configure) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var builder = new DefaultRazorEngineBuilder(designTime); AddDefaults(builder); if (designTime) { AddDefaultDesignTimeFeatures(configuration, builder.Features); } else { AddDefaultRuntimeFeatures(configuration, builder.Features); } configure?.Invoke(builder); return(builder.Build()); }
public DefaultRazorProjectEngine( RazorConfiguration configuration, RazorEngine engine, RazorProjectFileSystem fileSystem, IReadOnlyList <IRazorProjectEngineFeature> projectFeatures) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (engine == null) { throw new ArgumentNullException(nameof(engine)); } if (fileSystem == null) { throw new ArgumentNullException(nameof(fileSystem)); } if (projectFeatures == null) { throw new ArgumentNullException(nameof(projectFeatures)); } Configuration = configuration; Engine = engine; FileSystem = fileSystem; ProjectFeatures = projectFeatures; for (var i = 0; i < projectFeatures.Count; i++) { projectFeatures[i].ProjectEngine = this; } }
#pragma warning disable CS0618 // Type or member is obsolete private static RazorEngine CreateCore(RazorConfiguration configuration, bool designTime, Action <IRazorEngineBuilder> configure) #pragma warning restore CS0618 // Type or member is obsolete { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var builder = new DefaultRazorEngineBuilder(designTime); AddDefaults(builder); if (designTime) { AddDefaultDesignTimeFeatures(configuration, builder.Features); } else { AddDefaultRuntimeFeatures(configuration, builder.Features); } configure?.Invoke(builder); return(builder.Build()); }
public static RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem) => Create(configuration, fileSystem, configure: null);
protected RazorProjectEngine CreateProjectEngine() { var configuration = RazorConfiguration.Create(Version, "test", Array.Empty <RazorExtension>()); return(RazorProjectEngine.Create(configuration, RazorProjectFileSystem.Empty, ConfigureProjectEngine)); }