|
using System;
namespace Codebasement.DomainDrivenDesign.Basement.Attributes
{
/// <summary>
/// Attribute to define that a property must have a value, dependent on the value of another property in the same class.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public sealed class ConditionalDependencyAttribute : Attribute
{
private readonly string _propertyName;
private readonly string _propertyValue;
/// <summary>
/// Initializes a new instance of the <see cref="ConditionalDependencyAttribute"/> class.
/// This constructor enables conditional mandatoryness based on a property name and a specific property value.
/// </summary>
/// <param name="propertyName"></param>
/// <param name="propertyValue"></param>
public ConditionalDependencyAttribute(string propertyName, string propertyValue)
{
_propertyName = propertyName;
_propertyValue = propertyValue;
}
/// <summary>
/// Gets the property name.
/// </summary>
public string PropertyName
{
get { return _propertyName; }
}
/// <summary>
/// Gets the property value.
/// </summary>
public string PropertyValue
{
get { return _propertyValue; }
}
}
}
|
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.