// 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 System.Collections.Generic; using System.Linq; namespace Microsoft.AspNetCore.Razor.Language { public abstract class RequiredAttributeDescriptor : IEquatable { public string Name { get; protected set; } public NameComparisonMode NameComparison { get; protected set; } public string Value { get; protected set; } public ValueComparisonMode ValueComparison { get; protected set; } public string DisplayName { get; protected set; } public IReadOnlyList Diagnostics { get; protected set; } public bool HasErrors { get { var errors = Diagnostics.Any(diagnostic => diagnostic.Severity == RazorDiagnosticSeverity.Error); return errors; } } public override string ToString() { return DisplayName ?? base.ToString(); } public bool Equals(RequiredAttributeDescriptor other) { return RequiredAttributeDescriptorComparer.Default.Equals(this, other); } public override bool Equals(object obj) { return Equals(obj as RequiredAttributeDescriptor); } public override int GetHashCode() { return RequiredAttributeDescriptorComparer.Default.GetHashCode(this); } /// /// Acceptable comparison modes. /// public enum NameComparisonMode { /// /// HTML attribute name case insensitively matches . /// FullMatch, /// /// HTML attribute name case insensitively starts with . /// PrefixMatch, } /// /// Acceptable comparison modes. /// public enum ValueComparisonMode { /// /// HTML attribute value always matches . /// None, /// /// HTML attribute value case sensitively matches . /// FullMatch, /// /// HTML attribute value case sensitively starts with . /// PrefixMatch, /// /// HTML attribute value case sensitively ends with . /// SuffixMatch, } } }