C# 如果验证事件有两个不同的侦听器,其中一个设置Cancel=true,另一个设置Cancel=false,则会发生t?我和你有同样的感觉;这里的表面下潜藏着不好的东西;o) public delegate void ItemValidationEventHa
如果验证事件有两个不同的侦听器,其中一个设置Cancel=true,另一个设置Cancel=false,则会发生t?我和你有同样的感觉;这里的表面下潜藏着不好的东西;o)C# 如果验证事件有两个不同的侦听器,其中一个设置Cancel=true,另一个设置Cancel=false,则会发生t?我和你有同样的感觉;这里的表面下潜藏着不好的东西;o) public delegate void ItemValidationEventHa,c#,asp.net,events,eventargs,C#,Asp.net,Events,Eventargs,如果验证事件有两个不同的侦听器,其中一个设置Cancel=true,另一个设置Cancel=false,则会发生t?我和你有同样的感觉;这里的表面下潜藏着不好的东西;o) public delegate void ItemValidationEventHandler(object sender, ItemValidationEventArgs e); public class ItemValidationEventArgs : CancelEventArgs { public Item
public delegate void ItemValidationEventHandler(object sender, ItemValidationEventArgs e);
public class ItemValidationEventArgs : CancelEventArgs
{
public ItemValidationEventArgs(object item, ObjectAction state, EventArgs e)
{
Item = item;
State = state;
EventArgs = e;
}
public ItemValidationEventArgs(object item, ObjectAction state) : this(item, state, new EventArgs())
{
}
public ItemValidationEventArgs() : this(null, ObjectAction.None, new EventArgs())
{
}
// is there a better way to pass this info?
public string ErrorMessage {get; set;}
public int ErrorNumber {get;set;}
public object Item { get; private set; }
public ObjectAction State { get; private set; }
public EventArgs EventArgs { get; private set; }
}
virtual bool Validate(object item, ObjectAction action, out string errorMessage)
protected virtual bool Validate(object item);
class ValidationResult
{
public string ResultMessage{get;set;}
public bool IsValid {get;set;}
}
protected virtual ValidationResult Validate(object item)
{
ValidationResult result = new ValidationResult();
// validate and set results values accordingly
return result;
}