Implement a Property on an Editable Root List Object?

Implement a Property on an Editable Root List Object?

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


FrazerS posted on Monday, March 08, 2010

I want to implement a property on an ERL - the problem I am having is that in the DataPortal_Update method, the property value is the default value and not the value set when I created the ERL.  Is it possible to marshal a property value across the data portal line, and if so, how?

 

Frazer

 

FrazerS replied on Monday, March 08, 2010

Got it .


instead of referring to the property as MyProperty in DataPortal_Update, I simply changed it to this.MyProperty, and it worked.

Frazer

 

FrazerS replied on Monday, March 08, 2010

I was mistaken.  Original problem still exists.

 

Frazer

RockfordLhotka replied on Monday, March 08, 2010

If you are in .NET it should just work. Any fields defined in an object are, by default, serialized as part of the object state.

tmg4340 replied on Monday, March 08, 2010

IIRC, the CSLA collection classes aren't designed to have custom properties - managed or otherwise - on them.  As such, the DP isn't designed to handle them for you.

As Rocky mentioned, you can implement your own serialization code on the collections if you're in SL using the "state" methods.  In non-SL situations, I'm not sure what your options are.  The only serialization hook I know of is the OnDeserialized event, which doesn't give you access to the serialization stream used to hydrate the object.

- Scott

RockfordLhotka replied on Monday, March 08, 2010

In .NET only code, the BinaryFormatter and NDCS should just serialize any fields declared in the type. CSLA doesn't do any serialization in the .NET world, it lets .NET do that - and the .NET serializers should just take care of it.

FrazerS replied on Monday, March 08, 2010

Thanks, I have this working now.

Rocky - thanks for your help on this and other issues.  I think that if the Forum were not as responsive,  I would not have the confidence to choose CSLA for my applications.  Your apparently unflagging patience for questions (which must draw a sigh of exasperation from time to time) really make the difference.

thanks,

Frazer

RockfordLhotka replied on Monday, March 08, 2010

You mean a subclass of BusinessListBase? And this is Silverlight?

You need to override OnGetState and OnSetState to manually serialize/deserialize private field values through the MobileFormatter.

If the value is a primitive type (int, string, etc) this is easy. If the value is a reference to another object it is harder, and you need to override different methods.

Here's an eample for a primitive value:

    protected override void OnGetState(SerializationInfo info, StateMode mode)
    {
      base.OnGetState(info, mode);
      info.AddValue("Csla.Xaml.SingleCriteria._value", _value);
    }

    protected override void OnSetState(SerializationInfo info, StateMode mode)
    {
      base.OnSetState(info, mode);
      _value = info.GetValue<C>("Csla.Xaml.SingleCriteria._value");
    }
 

FrazerS replied on Monday, March 08, 2010

No, not SilverLight.  Does this impact your answer.  As I stated in my previous post, it appears that I am getting the value on the dataportal side now, simply by changing how I reference the property (this.MyProperty versus simply MyProperty)  however, I am now concerned that I am oversimplifying this and missing something fundamental.

 

Frazer

 

Copyright (c) Marimer LLC