using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel.DataAnnotations
{
///
/// An attribute used to specify the filtering behavior for a column.
///
[SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments", Justification = "ControlParameters is exposed, just with a different type")]
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public sealed class FilterUIHintAttribute : Attribute
{
private UIHintAttribute.UIHintImplementation _implementation;
///
/// Gets the name of the control that is most appropriate for this associated property or field
///
public string FilterUIHint
{
get
{
return this._implementation.UIHint;
}
}
///
/// Gets the name of the presentation layer that supports the control type in
///
public string PresentationLayer
{
get
{
return this._implementation.PresentationLayer;
}
}
///
/// Gets the name-value pairs used as parameters to the control's constructor
///
/// is thrown if the current attribute is ill-formed.
public IDictionary ControlParameters
{
get
{
return this._implementation.ControlParameters;
}
}
///
/// Constructor that accepts the name of the control, without specifying which presentation layer to use
///
/// The name of the UI control.
public FilterUIHintAttribute(string filterUIHint)
: this(filterUIHint, null, new object[0])
{
}
///
/// Constructor that accepts both the name of the control as well as the presentation layer
///
/// The name of the control to use
/// The name of the presentation layer that supports this control
public FilterUIHintAttribute(string filterUIHint, string presentationLayer)
: this(filterUIHint, presentationLayer, new object[0])
{
}
///
/// Full constructor that accepts the name of the control, presentation layer, and optional parameters
/// to use when constructing the control
///
/// The name of the control
/// The presentation layer
/// The list of parameters for the control
public FilterUIHintAttribute(string filterUIHint, string presentationLayer, params object[] controlParameters)
{
this._implementation = new UIHintAttribute.UIHintImplementation(filterUIHint, presentationLayer, controlParameters);
}
///
/// Returns the hash code for this FilterUIHintAttribute.
///
/// A 32-bit signed integer hash code.
public override int GetHashCode()
{
return this._implementation.GetHashCode();
}
///
/// Determines whether this instance of FilterUIHintAttribute and a specified object,
/// which must also be a FilterUIHintAttribute object, have the same value.
///
/// An System.Object.
/// true if obj is a FilterUIHintAttribute and its value is the same as this instance; otherwise, false.
public override bool Equals(object obj)
{
var otherAttribute = obj as FilterUIHintAttribute;
if (otherAttribute == null)
{
return false;
}
return this._implementation.Equals(otherAttribute._implementation);
}
}
}