StorageHandler Restore doesn't work with Mango?

Topics: Bugs, Framework Services
Aug 29, 2011 at 4:28 PM
Edited Aug 29, 2011 at 4:30 PM

Greetings,

I have an application where I have the following code:

    public class EditMyPreferencesTabViewModelStorage : StorageHandler<EditMyPreferencesTabViewModel>
    {
        public override void Configure()
        {
            Id(x => x.DisplayName);

            AddInstruction().Configure(x =>
            {
                x.Key = "MyPreference";

                x.Save = (instance, getKey, mode) =>
                {
                    var value = instance.MyPreference == null ? null : DataContractHelper<PreferenceModel>.Serialize(instance.MyPreference);

                    x.StorageMechanism.Store(getKey(), value);
                };

                x.Restore = (instance, getKey, mode) =>
                {
                    object value;
                    var key = getKey();

                    if (x.StorageMechanism.TryGet(key, out value))
                    {
                        instance.MyPreference = value == null ? null : DataContractHelper<PreferenceModel>.Deserialize((string)value);

                        x.StorageMechanism.Delete(key);
                    }
                };
            })
            .InPhoneState()
            .RestoreAfterActivation();
        }
    }

The code above worked just fine 5 weeks ago, before I updated my device to pre-Mango 7712 build and the developer tools to Beta2, but now, the "x.Restore" never runs and as such, the interface appears empty... any idea?

Aug 29, 2011 at 5:37 PM

Please disregard this topic, I since have found the problem was with the app life cycle...