examples of IMobileObject.GetChildren?

examples of IMobileObject.GetChildren?

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


swegele posted on Saturday, May 16, 2009

I have 2 DTO's

Investigator and InvestigatorMedLicense

I have implemented IMobileObject on both of them but I am not handling the InvestigatorMeedLicense properly because I get this error

Type 'IRB.DTO.InvestigatorMEDLicense[]' with data contract name 'ArrayOfInvestigatorMEDLicense' ....is not expected.

Can anyone guide me in how to implement the Get/Set Children on Investigator so that it is handled properly

Thanks

Sean

RockfordLhotka replied on Sunday, May 17, 2009

You will have a much easier time if you can inherit from the pre-build base classes in Csla.Core (MobileObject, MobileList, etc). Implementing IMobileObject is not trivial, especially with child objects.

But if you really must implement the interface yourself, then you should look at the base classes in Csla.Core, because you'll need to do exactly what they do. They are your guide.

swegele replied on Sunday, May 17, 2009

"ooo lala sasoon"!

That worked great Rocky...I didn't know about that mobile object & mobile list.  Even works with the shortened property syntax.

public Guid LocationID { get; set; }

One question in followup...will inheriting from MobileObject cause any complication in sharing out my DTO's to external partners (say to a BizTalk service bus at a partner)?

Sean

RockfordLhotka replied on Sunday, May 17, 2009

I can’t say for sure, but I don’t think so.

 

Most serializers simply reflect against your public properties to get/set the values. That’s true of the DCS and (in a way) the XmlSerializer for example.

 

The point is, those serializers don’t care what interfaces you implement, or what methods you have, or anything else – they ignore everything except for the get/set property behaviors.

 

The MobileFormatter, on the other hand, doesn’t use reflection because of the limitations on reflection in Silverlight. Instead, it relies on the cooperation of the object instance to load/unload the serialization stream. The IMobileObject interface defines the core behavior. But as you discovered, implementation of the interface (especially for contained objects) can be quite complex. The MobileXYZ base classes in Csla.Core are an attempt to provide the minimum necessary implementation of IMobileObject for various types (object, list, dictionary, etc) to simplify creation of types that work with MobileFormatter.

 

Rocky

 

 

From: swegele [mailto:cslanet@lhotka.net]
Sent: Sunday, May 17, 2009 11:45 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] examples of IMobileObject.GetChildren?

 

"ooo lala sasoon"!

That worked great Rocky...I didn't know about that mobile object & mobile list.  Even works with the shortened property syntax.

public Guid LocationID { get; set; }

One question in followup...will inheriting from MobileObject cause any complication in sharing out my DTO's to external partners (say to a BizTalk service bus at a partner)?

Sean



Copyright (c) Marimer LLC