Serialization.ISerializationNotification.RegisterEventHandlers

Serialization.ISerializationNotification.RegisterEventHandlers

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


jh72i posted on Monday, February 04, 2008

Hey folks,
I'm just wondering about the old ISerializationNotification interface and how I achieve what it used to do in the later versions of CSLA.  My question is specifically this - in the old days I used to unhook event handlers before serializing objects and hook event handlers on deserialization.  I just don't know where in the new framework I should be doing the unhook?  The hooking I understand I need to do in OnDeserialized() but where the unhook?

Thanks and thanks for the replies on other posts of mine - I'm trying to port everything i have over to newer versions so i have many 'earmarked' things i want to pursue when I can focus.

ajj3085 replied on Monday, February 04, 2008

What events do you need to unhook?  I would think you wouldn't want to unhook a root object listening to its children.  Are you talking about other objects listening to the events of a Csla object?

RockfordLhotka replied on Monday, February 04, 2008

Microsoft defined four attributes you can place on methods to indicate they should be called by the formatter. The OnDeserialized() method is the only one CSLA actually implements, because CSLA needs to react to deserialization. But you can define your own methods (the other three) with appropriate attributes and get notified of all the formatter's activity.

Look in BusinessBase to see how OnDeserialized() is invoked and you'll find the attribute and method signature. Then a little googling should get you the other three attributes and away you go.

jh72i replied on Tuesday, February 05, 2008

Thanks for those replies folks.  Rocky, as an interim solution I did copy your OnDeserialize... pattern for serialization.  That gives me backward compatibility.

ajj3085, mostly I just want to strip down any local connectivity when I send and object(as a data wrapper really) out onto the network. 

I do think, once I'm up an running again, that I'll have to rethink this in terms of the serializable/nonserializable event handlers might be doing what i need already.

Thanks again for the input.

Copyright (c) Marimer LLC