|
//-----------------------------------------------------------------------
// <copyright company="Microsoft">
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace System.Windows.Controls
{
/// <summary>
/// The source of a ValidationSummaryItem, indicating the PropertyName and/or Control.
/// </summary>
public class ValidationSummaryItemSource
{
/// <summary>
/// Initializes a new instance of the ValidationSummaryItemSource class.
/// </summary>
/// <param name="propertyName">The name of the property associated with this error.</param>
public ValidationSummaryItemSource(string propertyName) : this(propertyName, null)
{ }
/// <summary>
/// Initializes a new instance of the ValidationSummaryItemSource class.
/// </summary>
/// <param name="propertyName">The name of the property associated with this error.</param>
/// <param name="control">The control associated with this error.</param>
public ValidationSummaryItemSource(string propertyName, Control control)
{
this.PropertyName = propertyName;
this.Control = control;
}
/// <summary>
/// Gets the PropertyName.
/// </summary>
public string PropertyName
{
get;
private set;
}
/// <summary>
/// Gets the Control.
/// </summary>
public Control Control
{
get;
private set;
}
/// <summary>
/// Implements the equality check against the PropertyName and Control.
/// </summary>
/// <param name="obj">The ValidationSummaryItem being compared.</param>
/// <returns>A value indicating whether the two references are equal in value.</returns>
public override bool Equals(object obj)
{
ValidationSummaryItemSource other = obj as ValidationSummaryItemSource;
if (other == null)
{
return false;
}
return this.PropertyName == other.PropertyName && this.Control == other.Control;
}
/// <summary>
/// Returns a HashCode based on the PropertyName and Control Name
/// </summary>
/// <returns>The hash value of the ValidationSummaryItemSource.</returns>
public override int GetHashCode()
{
string sourceString = this.PropertyName + "." + this.Control.Name;
return sourceString.GetHashCode();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Weidong has been an information system professional since 1990. He has a Master's degree in Computer Science, and is currently a MCSD .NET