ValidationMethodAttribute Class
Apply this attribute to methods that should be invoked during validation.
Assembly: Microsoft.VisualStudio.Modeling.Sdk.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.12.0.dll)
System::Attribute
Microsoft.VisualStudio.Modeling.Validation::ValidationMethodAttribute
| Name | Description | |
|---|---|---|
![]() | ValidationMethodAttribute() | Apply this attribute to methods that you want to be called when the user invokes the Validate menu command. |
![]() | ValidationMethodAttribute(ValidationCategories) | Apply this attribute to methods that you want to be called during validation. |
| Name | Description | |
|---|---|---|
![]() | Categories | Defines when the method to which this attribute is applied will be called. |
![]() | CustomCategory | Gets or sets the custom validation category, which can be empty. |
![]() | TypeId | (Inherited from Attribute.) |
| Name | Description | |
|---|---|---|
![]() | Equals(Object^) | (Inherited from Attribute.) |
![]() | GetHashCode() | (Inherited from Attribute.) |
![]() | GetType() | (Inherited from Object.) |
![]() | IsDefaultAttribute() | (Inherited from Attribute.) |
![]() | Match(Object^) | (Inherited from Attribute.) |
![]() | ToString() | (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | _Attribute::GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) | (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfo(UInt32, UInt32, IntPtr) | (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfoCount(UInt32) | (Inherited from Attribute.) |
![]() ![]() | _Attribute::Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) | (Inherited from Attribute.) |
The Categories property determines when the attribute is used.
For more information, see Validation in a Domain-Specific Language.
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);
}
}
}
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.



