1: using System;
2: using System.Collections.Generic;
3: using System.Text;
4: using Microsoft.VisualStudio.Modeling.Diagrams;
5: using Microsoft.VisualStudio.Modeling.Validation;
6: using Microsoft.VisualStudio.Modeling;
7: using System.Globalization;
8:
9: // Como requisito da nossa maquina de estado que representa os nossos "Issues"
10: // ela nao pode ter estados cuja a propriedade Name e' vazio
11: // O metod abaixo verifica se nao estamos tentando criar uma classe ou estado
12: // cujo nome e' vazio, caso isto occora um erro deve ser gerado imediatamente
13:
14: // Ou seja um hard Validation
15:
16:
17: namespace Microsoft.IssueStateModels
18: {
19:
20: /// <summary>
21: /// Add a hard constraint to StateElement to prevent its "Name" property from being empty.
22: /// </summary>
23: public partial class StateElement
24: {
25: /// <summary>
26: /// Value handler for the NamedElement.Name domain property.
27: /// </summary>
28: internal sealed partial class NamePropertyHandler : DomainPropertyValueHandler<StateElement, global::System.String>
29: {
30: protected override void OnValueChanging(StateElement element, string oldValue, string newValue)
31: {
32: if (!element.Store.InUndoRedoOrRollback)
33: {
34: if (string.IsNullOrEmpty(newValue))
35: {
36: throw new ArgumentOutOfRangeException("Name", "Name cannot be empty or null.");
37: }
38: }
39: base.OnValueChanging(element, oldValue, newValue);
40: }
41: }
42: }
43: }