Criteria Properties in Domain Components
- 2 minutes to read
The example below illustrates how to implement Criteria Properties in a Domain Component interface.
[DomainComponent]
public interface ICriteriaProperties : INamedBaseObject {
[Browsable(false)]
string DataTypeName { get; set; }
[TypeConverter(typeof(LocalizedClassInfoTypeConverter))]
[ImmediatePostData, NonPersistentDc]
Type DataType { get; set; }
[CriteriaOptions("DataType")]
[FieldSize(SizeAttribute.Unlimited), ObjectValidatorIgnoreIssue(typeof(ObjectValidatorLargeNonDelayedMember))]
[ModelDefault("RowCount", "0")]
[VisibleInListView(true)]
[EditorAlias(EditorAliases.CriteriaPropertyEditor)]
string Criteria { get; set; }
[CriteriaOptions("DataType")]
[FieldSize(SizeAttribute.Unlimited), ObjectValidatorIgnoreIssue(typeof(ObjectValidatorLargeNonDelayedMember))]
[ModelDefault("RowCount", "0")]
[VisibleInListView(true)]
[EditorAlias(EditorAliases.PopupCriteriaPropertyEditor)]
string CriteriaInPopupWindow { get; set; }
[CriteriaOptions("DataType")]
[FieldSize(SizeAttribute.Unlimited), ObjectValidatorIgnoreIssue(typeof(ObjectValidatorLargeNonDelayedMember))]
[ModelDefault("RowCount", "0")]
[VisibleInListView(true)]
[EditorAlias(EditorAliases.ExtendedCriteriaPropertyEditor)]
string ExtendedCriteria { get; set; }
}
[DomainLogic(typeof(ICriteriaProperties))]
public class ICriteriaProperties_Logic {
private Type dataType;
public void BeforeChange_DataTypeName(ICriteriaProperties obj, IObjectSpace objectSpace, string value) {
Type type = XafTypesInfo.Instance.FindTypeInfo(value) == null ? null : XafTypesInfo.Instance.FindTypeInfo(value).Type;
if (obj.DataType != type) {
obj.DataType = type;
}
if (value != obj.DataTypeName) {
obj.Criteria = String.Empty;
obj.CriteriaInPopupWindow = String.Empty;
obj.ExtendedCriteria = String.Empty;
}
}
public void AfterChange_DataType(ICriteriaProperties obj, IObjectSpace objectSpace, Type value) {
obj.DataTypeName = (value == null) ? null : value.FullName;
}
public Type DataType {
get { return dataType; }
set {
if (dataType != value) {
dataType = value;
}
}
}
}
See the CriteriaOptionsAttribute attribute description for details on using this attribute.