| File: Language\Extensions\RazorCompiledItemMetadataAttributeIntermediateNode.cs | Web Access |
| Project: src\roslyn\src\Razor\src\Compiler\Microsoft.CodeAnalysis.Razor.Compiler\src\Microsoft.CodeAnalysis.Razor.Compiler.csproj (Microsoft.CodeAnalysis.Razor.Compiler) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable disable using System; using Microsoft.AspNetCore.Razor.Language.CodeGeneration; using Microsoft.AspNetCore.Razor.Language.Intermediate; namespace Microsoft.AspNetCore.Razor.Language.Extensions; /// <summary> /// An <see cref="ExtensionIntermediateNode"/> that generates code for <c>RazorCompiledItemMetadataAttribute</c>. /// </summary> public class RazorCompiledItemMetadataAttributeIntermediateNode : ExtensionIntermediateNode { public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly; /// <summary> /// Gets or sets the attribute key. /// </summary> public string Key { get; set; } /// <summary> /// Gets or sets the attribute value. /// </summary> public string Value { get; set; } /// <summary> /// Gets or sets an optional string syntax for the <see cref="Value"/> /// </summary> public string ValueStringSyntax { get; set; } 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<IMetadataAttributeTargetExtension>(); if (extension == null) { ReportMissingCodeTargetExtension<IMetadataAttributeTargetExtension>(context); return; } extension.WriteRazorCompiledItemMetadataAttribute(context, this); } public override void FormatNode(IntermediateNodeFormatter formatter) { formatter.WriteProperty(nameof(Key), Key); formatter.WriteProperty(nameof(Value), Value); formatter.WriteProperty(nameof(ValueStringSyntax), ValueStringSyntax); } }