public delegate void UnSafeProcedure();
public class BasePage : System.Web.UI.Page
{
public CAssertions assert= new CAssertions(); // my own assertor, produce AssertionException
public void RunSafe(UnSafeProcedure s)
{
try
{
s();
}
catch (Exception e1)
{
if (e1.GetType().FullName == "AssertionException")
{
ShowMessage(e1.Message);
}
else
{
ShowMessage("Unhandled Exception");
Debug.Write(e1.ToString());
}
}
}
// will be overwrited on actual page:
public virtual void ShowMessage(string s) { Debug.Write(s); }
}
This is how actual page would look like:
public partial class NewEft : BasePage {
protected void SubmitButtonClick(object sender, EventArgs e) {
RunSafe(Submit);
}
private void Submit() {
AUtyl butyl = new AUtyl();
assert.IsTrue(butyl.CheckRoutingNumberByRouting(txtRoutingNumber.Text), "Routing Number is invalid");
}
public override void ShowMessage (string s ) { lblMessage.Text = s; }
}
more...
2 comments:
hi..
can u help me to select the content of ms.word from ruby??
i have a proble with it..
it also can be run as anonymous function without creation "Unsafe" function like this :
RunSafe(delegate() {
/// unsafee code here
});
Post a Comment