Made CodeTargetBuilder an abstract class

This commit is contained in:
Ajay Bhargav Baaskaran 2017-07-06 19:01:28 -07:00
parent d6e892b30c
commit 49eab41726
7 changed files with 31 additions and 31 deletions

View File

@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
public static CodeTarget CreateDefault( public static CodeTarget CreateDefault(
RazorCodeDocument codeDocument, RazorCodeDocument codeDocument,
RazorCodeGenerationOptions options, RazorCodeGenerationOptions options,
Action<ICodeTargetBuilder> configure) Action<CodeTargetBuilder> configure)
{ {
if (codeDocument == null) if (codeDocument == null)
{ {
@ -59,7 +59,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
public static CodeTarget CreateEmpty( public static CodeTarget CreateEmpty(
RazorCodeDocument codeDocument, RazorCodeDocument codeDocument,
RazorCodeGenerationOptions options, RazorCodeGenerationOptions options,
Action<ICodeTargetBuilder> configure) Action<CodeTargetBuilder> configure)
{ {
if (codeDocument == null) if (codeDocument == null)
{ {
@ -76,12 +76,12 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
return builder.Build(); return builder.Build();
} }
internal static void AddDesignTimeDefaults(ICodeTargetBuilder builder) internal static void AddDesignTimeDefaults(CodeTargetBuilder builder)
{ {
} }
internal static void AddRuntimeDefaults(ICodeTargetBuilder builder) internal static void AddRuntimeDefaults(CodeTargetBuilder builder)
{ {
} }

View File

@ -0,0 +1,18 @@
// 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.Collections.Generic;
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
{
public abstract class CodeTargetBuilder
{
public abstract RazorCodeDocument CodeDocument { get; }
public abstract RazorCodeGenerationOptions Options { get; }
public abstract ICollection<ICodeTargetExtension> TargetExtensions { get; }
public abstract CodeTarget Build();
}
}

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
{ {
internal class DefaultCodeTargetBuilder : ICodeTargetBuilder internal class DefaultCodeTargetBuilder : CodeTargetBuilder
{ {
public DefaultCodeTargetBuilder(RazorCodeDocument codeDocument, RazorCodeGenerationOptions options) public DefaultCodeTargetBuilder(RazorCodeDocument codeDocument, RazorCodeGenerationOptions options)
{ {
@ -16,13 +16,13 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
TargetExtensions = new List<ICodeTargetExtension>(); TargetExtensions = new List<ICodeTargetExtension>();
} }
public RazorCodeDocument CodeDocument { get; } public override RazorCodeDocument CodeDocument { get; }
public RazorCodeGenerationOptions Options { get; } public override RazorCodeGenerationOptions Options { get; }
public ICollection<ICodeTargetExtension> TargetExtensions { get; } public override ICollection<ICodeTargetExtension> TargetExtensions { get; }
public CodeTarget Build() public override CodeTarget Build()
{ {
return new DefaultCodeTarget(Options, TargetExtensions); return new DefaultCodeTarget(Options, TargetExtensions);
} }

View File

@ -1,18 +0,0 @@
// 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.Collections.Generic;
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
{
public interface ICodeTargetBuilder
{
RazorCodeDocument CodeDocument { get; }
RazorCodeGenerationOptions Options { get; }
ICollection<ICodeTargetExtension> TargetExtensions { get; }
CodeTarget Build();
}
}

View File

@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.Razor.Language
}); });
} }
protected virtual void ConfigureTarget(ICodeTargetBuilder builder) protected virtual void ConfigureTarget(CodeTargetBuilder builder)
{ {
// Intentionally empty. // Intentionally empty.
} }

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
{ {
// Arrange // Arrange
var wasCalled = false; var wasCalled = false;
Action<ICodeTargetBuilder> @delegate = (b) => { wasCalled = true; }; Action<CodeTargetBuilder> @delegate = (b) => { wasCalled = true; };
var codeDocument = TestRazorCodeDocument.CreateEmpty(); var codeDocument = TestRazorCodeDocument.CreateEmpty();
var options = RazorCodeGenerationOptions.CreateDefault(); var options = RazorCodeGenerationOptions.CreateDefault();

View File

@ -248,7 +248,7 @@ namespace Microsoft.AspNetCore.Razor.Language
public bool ShouldMatch { get; set; } = true; public bool ShouldMatch { get; set; } = true;
public Action<ICodeTargetBuilder> CodeTargetCallback { get; set; } public Action<CodeTargetBuilder> CodeTargetCallback { get; set; }
public string Namespace { get; set; } public string Namespace { get; set; }
@ -274,7 +274,7 @@ namespace Microsoft.AspNetCore.Razor.Language
@method.MethodName = Method; @method.MethodName = Method;
} }
protected override void ConfigureTarget(ICodeTargetBuilder builder) protected override void ConfigureTarget(CodeTargetBuilder builder)
{ {
CodeTargetCallback?.Invoke(builder); CodeTargetCallback?.Invoke(builder);
} }