Saved event

Saved event

Old forum URL: forums.lhotka.net/forums/t/3250.aspx


juddaman posted on Monday, July 23, 2007

When cloning a BusinessBase subclass should the new object have the same list of event subscribers as the original?

As in the example project shows the object been cloned before the Save method is called on the new object. However this means the Saved event is never fired. For example:

private void Save()
{
      _project.Saved += new EventHandler<Csla.Core.SavedEventArgs>(_project_Saved);
      Project temp = _project.Clone();
      _project = temp.Save();
}

void _project_Saved(object sender, Csla.Core.SavedEventArgs e)
    {
                 // Doesn't get fired
      }

Is this 'by design' or a bug?

Thanks

George

RockfordLhotka replied on Monday, July 23, 2007

The event handling issues are discussed in Chapter 3 - look at the bit about BindableBase. There are also some blog posts on www.lhotka.net/weblog about this - from 2005 though, so you'll have to dig back a bit.

Some event handlers will remain, some need to be reconnected - it all depends on whether the object containing the event handler method is serializable or not.

Copyright (c) Marimer LLC