/// <summary>
        /// Restores the data after view's Loaded event is raised.
        /// </summary>
        /// <typeparam name="T">The model type.</typeparam>
        /// <param name="builder">The builder.</param>
        /// <returns>The builder.</returns>
        public static StorageInstructionBuilder <T> RestoreAfterViewLoad <T>(this StorageInstructionBuilder <T> builder)
            where T : IViewAware
        {
            return(builder.Configure(x => {
                var original = x.Restore;

                x.Restore = (instance, getKey, mode) => {
                    EventHandler <ViewAttachedEventArgs> onViewAttached = null;
                    onViewAttached = (s, e) => {
                        var fe = (FrameworkElement)e.View;
                        View.ExecuteOnLoad(fe, (s2, e2) => { original(instance, getKey, mode); });
                        instance.ViewAttached -= onViewAttached;
                    };
                    instance.ViewAttached += onViewAttached;
                };
            }));
        }
        /// <summary>
        /// Restores the data after view's LayoutUpdated event is raised.
        /// </summary>
        /// <typeparam name="T">The model type.</typeparam>
        /// <param name="builder">The builder.</param>
        /// <returns>The builder.</returns>
        public static StorageInstructionBuilder <T> RestoreAfterViewReady <T>(this StorageInstructionBuilder <T> builder)
            where T : IViewAware
        {
            return(builder.Configure(x => {
                var original = x.Restore;

                x.Restore = (instance, getKey, mode) => {
                    EventHandler <ViewAttachedEventArgs> onViewAttached = null;
                    onViewAttached = (s, e) => {
                        var fe = (FrameworkElement)e.View;
                        instance.ViewAttached -= onViewAttached;
                        EventHandler <object> handler = null;
                        handler = (s2, e2) => {
                            original(instance, getKey, mode);
                            fe.LayoutUpdated -= handler;
                        };
                        fe.LayoutUpdated += handler;
                    };
                    instance.ViewAttached += onViewAttached;
                };
            }));
        }
        /// <summary>
        /// Restores the data when IActivate.Activated is raised.
        /// </summary>
        /// <typeparam name="T">The model type.</typeparam>
        /// <param name="builder">The builder.</param>
        /// <returns>The builder.</returns>
        public static StorageInstructionBuilder <T> RestoreAfterActivation <T>(this StorageInstructionBuilder <T> builder)
            where T : IActivate
        {
            return(builder.Configure(x => {
                var original = x.Restore;

                x.Restore = (instance, getKey, mode) => {
                    if (instance.IsActive)
                    {
                        original(instance, getKey, mode);
                    }
                    else
                    {
                        EventHandler <ActivationEventArgs> onActivate = null;
                        onActivate = (s, e) => {
                            original(instance, getKey, mode);
                            instance.Activated -= onActivate;
                        };
                        instance.Activated += onActivate;
                    }
                };
            }));
        }
 /// <summary>
 /// Stores the data in the permanent ApplicationSettings.
 /// </summary>
 /// <typeparam name="T">The model type.</typeparam>
 /// <param name="builder">The builder.</param>
 /// <returns>The builder.</returns>
 public static StorageInstructionBuilder <T> InAppSettings <T>(this StorageInstructionBuilder <T> builder)
 {
     return(builder.Configure(x => { x.StorageMechanism = x.Owner.Coordinator.GetStorageMechanism <AppSettingsStorageMechanism>(); }));
 }
 /// <summary>
 /// Stores data in roaming storage, beware the 100k size limit
 /// </summary>
 public static StorageInstructionBuilder <T> InRoamingStorage <T>(this StorageInstructionBuilder <T> builder)
 {
     return(builder.Configure(x => { x.StorageMechanism = x.Owner.Coordinator.GetStorageMechanism <WinRTRoamingStorageMechanism>(); }));
 }