// 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 Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.CodeGeneration; using Microsoft.AspNetCore.Razor.Language.Intermediate; namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X { public class InjectIntermediateNode : ExtensionIntermediateNode { public string TypeName { get; set; } public string MemberName { get; set; } public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly; public override void Accept(IntermediateNodeVisitor visitor) { if (visitor == null) { throw new ArgumentNullException(nameof(visitor)); } AcceptExtensionNode(this, visitor); } public override void WriteNode(CodeTarget target, CodeRenderingContext context) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } var extension = target.GetExtension(); if (extension == null) { ReportMissingCodeTargetExtension(context); return; } extension.WriteInjectProperty(context, this); } } }