ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles Bayon" <ibatis....@gmail.com>
Subject Re: svn commit: r664536 [1/4]...EventHandler/EventArgs?
Date Mon, 09 Jun 2008 06:20:20 GMT
The .NET event pattern cannot be used here, it follows the pattern fire and
forget, and it's not what I'm searching as I want to be able to interact
with the DataMapper workflow engine, you must see them as extension point
where you can change the items that the engine is working on.
It can be used for all sorts of cross-cutting concerns

Example, replace the resultMap object instance by a proxy one, add/change
arguments used by the constructor in the resultMap...

private class MyPreCreateEventListener : PreCreateEventListener
    /// <summary>
    /// Calls before creating an instance of the <see cref="IResultMap"/>
    /// </summary>
    /// <param name="evnt">The event.</param>
    /// <returns>
    /// Returns is used as constructor arguments for the instance being
    /// </returns>
    public override object OnEvent(PreCreateEvent evnt)
    evnt.Parameters[evnt.Parameters.Length-1] = "new lastName";

    return evnt.Parameters;


private class MyPreInsertEventListener :PreInsertEventListener

    /// <summary>
    /// Calls on the specified event.
    /// </summary>
    /// <param name="evnt">The event.</param>
    /// <returns>Returns is used as the parameter object</returns>
    public override object OnEvent(PreInsertEvent evnt)
    IDomain domain = evnt.ParameterObject as IDomain;
        if (domain != null)

    return account;

    private void ProcessBeforeInsert(IDomain domain)
        User user = (User) Thread.CurrentPrincipal;
        domain.CreatedBy = user.UserName;
        domain.ModifiedBy = user.UserName;
        domain.CreatedDate = DateTime.Now;
        domain.ModifiedDate = DateTime.Now;


View raw message