ValidationCategories Enumeration

This enumeration is a parameter for the constructor of the custom attribute, ValidationMethodAttribute. It specifies the type of validation in which the rule will be invoked.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

Namespace:  Microsoft.VisualStudio.Modeling.Validation
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.12.0.dll)

[FlagsAttribute]
public enum ValidationCategories

Member nameDescription
CustomThe method is for custom validation. To run this method, you can call ValidationController.ValidateCustom().
LoadUse this category for rules that check for conditions that will keep the model from loading. The method is invoked before a domain-specific language model is saved, to give the user a chance to correct any problems.

If a Load rule fails when the model is loaded, the model file will be opened with the XML editor rather than the DSL Designer.

MenuThe method is invoked when the user selects ValidateAll on the shortcut menu.
OpenThe validation method is invoked when the model is opened.
SaveIndicates that the validation method is invoked before a user of the domain-specific language saves the model.

This is a bitwise enumeration. The flags are not mutually exclusive.

The following example shows the ValidationCategory of a method in the Person class that is invoked when the user of a domain-specific language opens a model, saves a model, or clicks the validation command on the shortcut menu.

[C#]

[ValidationMethod
(
    ValidationCategories.Open |
    ValidationCategories.Save |
    ValidationCategories.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);
        }
    }
}
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft