Assuming that the OnDelte method knows about the entity in question, the entity could implement an interface called IPersistable. This interface could have a boolean property AllowDelete.
In the delete event try to cast the entity as IPersistable. If the cast succeeds allow the delete by setting AllowDelete = true.
i.e.
public void Delete()
{
IPersistable persistableEntity = currentEntity as IPersistable;
If (persistableEntity != null)
persistableEntity.AllowDelete = true;
}
You could as you suggest raise another event that sent custom event args an pass your instance of persistableEntity in the args.
Another option could be to simply check the entity in the control and let the control decide to delete it or not.
public void Delete()
{
IPersistable persistableEntity = currentEntity as IPersistable;
If (persistableEntity != null && persistableEntity.AllowDelete)
//..... code in the control to run the delete logic
}
Another even more abstract approach would be to define a custom attribute and decorate your entity class with the attribute.
[PersistableAttribute(AllowDelete:=true)]
public class OrdersEntity()
{
}
If you used the attribute approach you could simply use reflection to check the type at runtime for the PersitableAttribute and the AllowDelete property. The attribute approach only works well if the behavior is consistent, i.e. if your scenario dictacts that your control will ALWAYS skip the delete code for the OrderEntity then this would work great. If the "Deleteability" of a given entity is dynamic and could change at runtime, then the attribute approach isnt what you need.