public static CodeTarget CreateDefault( RazorCodeDocument codeDocument, RazorCodeGenerationOptions options, Action <CodeTargetBuilder> configure) { if (codeDocument == null) { throw new ArgumentNullException(nameof(codeDocument)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } var builder = new DefaultCodeTargetBuilder(codeDocument, options); if (builder.Options.DesignTime) { AddDesignTimeDefaults(builder); } else { AddRuntimeDefaults(builder); } if (configure != null) { configure.Invoke(builder); } return(builder.Build()); }
public void Build_CreatesDefaultCodeTarget() { // Arrange var codeDocument = TestRazorCodeDocument.CreateEmpty(); var options = RazorCodeGenerationOptions.CreateDefault(); var builder = new DefaultCodeTargetBuilder(codeDocument, options); var extensions = new ICodeTargetExtension[] { new MyExtension1(), new MyExtension2(), }; for (var i = 0; i < extensions.Length; i++) { builder.TargetExtensions.Add(extensions[i]); } // Act var result = builder.Build(); // Assert var target = Assert.IsType <DefaultCodeTarget>(result); Assert.Equal(extensions, target.Extensions); }
public static CodeTarget CreateEmpty( RazorCodeDocument codeDocument, RazorCodeGenerationOptions options, Action <CodeTargetBuilder> configure) { if (codeDocument == null) { throw new ArgumentNullException(nameof(codeDocument)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } var builder = new DefaultCodeTargetBuilder(codeDocument, options); configure?.Invoke(builder); return(builder.Build()); }