Re: Using generic EventArgs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Duniho

    Re: Using generic EventArgs

    On Mon, 28 Jul 2008 12:04:49 -0700, Andrus <kobruleht2@hot .eewrote:
    [...]
    public class CellValidatedEv entArgs<TRow: EventArgs
    where TRow : class , IRow
    {
    [...]
    }
    >
    >
    My entity base class contains empty method to allow override :
    >
    class EntityBase {
    public virtual void OnRowCellValida ted<TRow>(TRow sender,
    CellValidatedEv entArgs<TRowe)
    where TRow : class, IRow { }
    }
    >
    Is this best design pattern ?
    "Best" is such a hard thing to say for sure.

    I will point out that the usual .NET pattern is for the "sender" parameter
    to simply be of type Object. I will also point out that the usual .NET
    pattern has the "sender" being the instance of the class implementing the
    "OnXXX()" method. If, as Ignacio suggests, the EntityBase class is
    inherited by whatever TRow winds up being, the example you give seems fine
    but you should constrain TRow to match. On the other hand, if TRow is not
    derived from EntityBase, then perhaps the EntityBase class isn't the best
    place to put the event and related implementation.

    All that said, I don't see anything fundamentally wrong with what you
    posted, so far as it goes. There's not enough detail to assess whether
    it's good _or_ bad.

    Pete
Working...