MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

ViewModelBase.cs - on ANDROID and IOS ManageObjectLifetimeProperty should default to true #24

Closed tfreitasleal closed 9 years ago

tfreitasleal commented 9 years ago

Source from 4.5.x branch, on ViewModelBase.cs we can read

if ANDROID || IOS

public bool ManageObjectLifetimeProperty;

else

public static readonly DependencyProperty ManageObjectLifetimeProperty =
    DependencyProperty.Register("ManageObjectLifetime", typeof(bool),
    typeof(ViewModelBase<T>), new PropertyMetadata(true));

endif

On ANDROID and IOS shouldn't ManageObjectLifetimeProperty default value be "true"?

if ANDROID || IOS

public bool ManageObjectLifetimeProperty = true;

else

....

Rocky,

Although I have a signed a contribution agreement, I don't think I should commit these changes since I have no way to test them (I not running Xamarin). BTW I'm porting this class to WindowsForms and found interesting to see what was done on another non DP platform.

rockfordlhotka commented 9 years ago

iirc, we chose to make the default false on mobile devices to avoid consuming memory.

When this value is set to true the viewmodel will automatically call BeginEdit on the object, causing the object graph to be serialized into a memory copy. On a full-blown computer this is typically a non-issue, but on a mobile device it consumes power and memory that might be scarce.

So the thought was that the developer should opt-in to such a cost rather than having it be the default.