OnDeserializedInternal and SetParent

OnDeserializedInternal and SetParent

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


trives posted on Monday, September 29, 2008

I see in BusinessListBase there is an OnDeserializedInternal method that takes care of reestablishing the Parent property for the collection's children (child.SetParent()).

In BusinessBase, there is also an OnDeserializedInternal method, but I don't see where the Parent property is being reestablished for children of the business object. 

My understanding from Rocky's post here http://forums.lhotka.net/forums/post/20371.aspx is that deserialization should restore the Parent property for BO and BLB child objects.

Did I misunderstand or am I just not seeing where this is happening?  If the later, can someone point out where this is happening?

Thanks.

sergeyb replied on Monday, September 29, 2008

This is done for managed properties in FieldDataDeserialized() method called from OnDeserializedInternal().

 

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: trives [mailto:cslanet@lhotka.net]
Sent: Monday, September 29, 2008 10:54 AM
To: Sergey Barskiy
Subject: [CSLA .NET] OnDeserializedInternal and SetParent

 

I see in BusinessListBase there is an OnDeserializedInternal method that takes care of reestablishing the Parent property for the collection's children (child.SetParent()).

In BusinessBase, there is also an OnDeserializedInternal method, but I don't see where the Parent property is being reestablished for children of the business object. 

My understanding from Rocky's post here http://forums.lhotka.net/forums/post/20371.aspx is that deserialization should restore the Parent property for BO and BLB child objects.

Did I misunderstand or am I just not seeing where this is happening?  If the later, can someone point out where this is happening?

Thanks.



trives replied on Monday, September 29, 2008

Thanks Sergey. 

For anyone interested, the version of BusinessBase from cslacs-3.6.0-080919.zip, which is what I was using, looks like this:

    private void FieldDataDeserialized()
    {
      foreach (object item in FieldManager.GetChildren())
      {
        IBusinessObject business = item as IBusinessObject;
        if (business != null)
          OnAddEventHooksInternal(business);
      }
    }

It doesn't contain any calls to SetParent().

The most recent version of BusinessBase from cslacs-3.6.0-080926.zip looks like this:

    private void FieldDataDeserialized()
    {
      foreach (object item in FieldManager.GetChildren())
      {
        IBusinessObject business = item as IBusinessObject;
        if (business != null)
          OnAddEventHooksInternal(business);

        IEditableBusinessObject child = item as IEditableBusinessObject;
        if (child != null)
        {
          child.SetParent(this);
        }
        IEditableCollection childCollection = item as IEditableCollection;
        if (childCollection != null)
        {
          childCollection.SetParent(this);
        }
      }
    }

Now, this makes sense.

Copyright (c) Marimer LLC