| File: Language\TagHelperAttributeMatch.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. using System; using System.Diagnostics.CodeAnalysis; using Microsoft.AspNetCore.Razor.Language.Components; namespace Microsoft.AspNetCore.Razor.Language; internal struct TagHelperAttributeMatch( string name, BoundAttributeDescriptor attribute, BoundAttributeParameterDescriptor? parameter = null) { public string Name { get; } = name; public BoundAttributeDescriptor Attribute { get; } = attribute; public BoundAttributeParameterDescriptor? Parameter { get; } = parameter; private bool? _isIndexerMatch; public bool IsIndexerMatch => _isIndexerMatch ??= TagHelperMatchingConventions.SatisfiesBoundAttributeIndexer(Attribute, Name.AsSpan()); [MemberNotNullWhen(true, nameof(Parameter))] public readonly bool IsParameterMatch => Parameter is not null; public bool ExpectsStringValue { get { if (IsParameterMatch) { return Parameter.IsStringProperty; } return Attribute.IsStringProperty || Attribute.AcceptsStringLiteral() || (IsIndexerMatch && Attribute.IsIndexerStringProperty); } } public bool ExpectsBooleanValue { get { if (IsParameterMatch) { return Parameter.IsBooleanProperty; } return Attribute.IsBooleanProperty || (IsIndexerMatch && Attribute.IsIndexerBooleanProperty); } } }