|
Hi smi-mark;
I've tested the buddy class method of adding the verifier and it seems to work for me. Perhaps I misunderstood something specific to your use case?
Here's my test.
//The NullEntityVerifier
public class NullEntityVerifier : PropertyValueVerifier { public NullEntityVerifier(Type entityType, String propertyName, String displayName = null, bool? shouldTreatEmptyStringAsNull = null) : base(new PropertyValueVerifierArgs(entityType, propertyName, false, displayName, shouldTreatEmptyStringAsNull)) { }
public NullEntityVerifier(PropertyValueVerifierArgs args) : base(args) { }
protected override VerifierResult VerifyValue(object itemToVerify, object valueToVerify, TriggerContext triggerContext, VerifierContext verifierContext) {
var entity = (Entity)valueToVerify; var result = !entity.EntityAspect.IsNullEntity; return new VerifierResult(result); } }
//The NullEntityVerifierAttribute
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = false)] public class NullEntityVerifierAttribute : PropertyValueVerifierAttribute { protected override Verifier BuildVerifierCore(Type pType, String propertyName) { return new NullEntityVerifier( new PropertyValueVerifierArgs(pType, propertyName, false, DisplayName, GetShouldTreatEmptyStringAsNull()) ); } }
//The buddy class
public class EmployeeMetadata {
[NullEntityVerifier] public static Employee Manager; }
//The generated code
#region Manager property
/// <summary>Gets or sets the Manager. </summary> [DomainModel.Employee.NullEntityVerifier] [Bindable(false)] [Display(Name="Manager", AutoGenerateField=false)] [DataMember] [IbEm.RelationProperty("FK_Employee_Employee", IbEm.QueryDirection.ToRole2)] public Employee Manager { get { return PropertyMetadata.Manager.GetValue(this); } set { PropertyMetadata.Manager.SetValue(this, value); } } #endregion Manager property
|