-
Notifications
You must be signed in to change notification settings - Fork 1
/
ViewVariantParameterObject.cs
38 lines (37 loc) · 1.37 KB
/
ViewVariantParameterObject.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.ComponentModel;
using DevExpress.ExpressApp.DC;
using DevExpress.ExpressApp.Model;
using DevExpress.Persistent.Validation;
using DevExpress.ExpressApp.ViewVariantsModule;
namespace UserViewVariants {
[DomainComponent]
[DefaultProperty("Caption")]
public class ViewVariantParameterObject {
private readonly IModelList<IModelVariant> variants;
public ViewVariantParameterObject(IModelList<IModelVariant> variants) {
this.variants = variants;
}
[RuleFromBoolProperty(
"RuleFromBoolProperty_ViewVariantParameterObject.IsUniqueCaption",
"AddViewVariantContext",
UsedProperties = "Caption",
CustomMessageTemplate = "You must specify a different value, because there is already a view variant with the same caption."
)]
[Browsable(false)]
public bool IsUniqueCaption {
get {
bool ok = true;
foreach (IModelVariant variant in variants) {
if (variant.Caption == Caption) {
ok = false;
break;
}
}
return ok;
}
}
[RuleRequiredField("RuleRequiredField_ViewVariantParameterObject.Caption", "AddViewVariantContext")]
public string Caption { get; set; }
}
}