Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

50 lines
1.6 KiB
C#

// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using Microsoft.Internal.Web.Utils;
namespace System.Web.Razor
{
/// <summary>
/// Specifies a Razor directive that is rendered as an attribute on the generated class.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class RazorDirectiveAttribute : Attribute
{
private readonly object _typeId = new object();
public RazorDirectiveAttribute(string name, string value)
{
if (String.IsNullOrEmpty(name))
{
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "name");
}
Name = name;
Value = value;
}
public override object TypeId
{
get { return _typeId; }
}
public string Name { get; private set; }
public string Value { get; private set; }
public override bool Equals(object obj)
{
RazorDirectiveAttribute attribute = obj as RazorDirectiveAttribute;
return attribute != null &&
Name.Equals(attribute.Name, StringComparison.OrdinalIgnoreCase) &&
StringComparer.OrdinalIgnoreCase.Equals(Value, attribute.Value);
}
public override int GetHashCode()
{
return (StringComparer.OrdinalIgnoreCase.GetHashCode(Name) * 31) +
(Value == null ? 0 : StringComparer.OrdinalIgnoreCase.GetHashCode(Value));
}
}
}