Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Represents an attribute that can be used during validation.
Namespace: Microsoft.VisualStudio.Modeling.Validation
Assembly: Microsoft.VisualStudio.Modeling.Sdk (in Microsoft.VisualStudio.Modeling.Sdk.dll)
Syntax
'Declaration
<AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple := True)> _
Public NotInheritable Class ValidationMethodAttribute _
Inherits Attribute
'Usage
Dim instance As ValidationMethodAttribute
[AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple = true)]
public sealed class ValidationMethodAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Method, AllowMultiple = true)]
public ref class ValidationMethodAttribute sealed : public Attribute
public final class ValidationMethodAttribute extends Attribute
Remarks
The Categories property determines when the attribute is used.
For more information about validation, see Walkthrough: Adding Validation to a Domain Model.
Examples
The following example decorates a method in the Person class to be invoked when validation occurs. The ValidationCategories enumeration setting indicates when the method will be invoked.
[C#]
[ValidationMethod
(
ValidationCategory.Open |
ValidationCategory.Save |
ValidationCategory.Menu
)
]
private void ValidateParentBirth(ValidationContext context)
{
foreach (Person parent in this.Parent)
{
if (this.Birth <= parent.Birth)
{
context.LogError(
"Birth must be after parent's birth",
"FamilyParentBirthError",
this,
parent);
}
}
}
Inheritance Hierarchy
System.Object
System.Attribute
Microsoft.VisualStudio.Modeling.Validation.ValidationMethodAttribute
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.