Exemplo n.º 1
0
        static async public Task Save <T>()
        {
            try
            {
                if (await DoesFileExistAsync())
                {
                    await Windows.System.Threading.ThreadPool.RunAsync((sender)
                                                                       => PatternData.SaveAsync <T>().Wait(), Windows.System.Threading.WorkItemPriority.Normal);
                }
                else
                {
                    file = await ApplicationData.Current.LocalFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);

                    await Windows.System.Threading.ThreadPool.RunAsync((sender)
                                                                       => PatternData.SaveAsync <T>().Wait(), Windows.System.Threading.WorkItemPriority.Normal);
                }
            }
            catch (AggregateException ae)
            {
                ae.Handle((x) =>
                {
                    if (x is UnauthorizedAccessException) // This we know how to handle.
                    {
                        new MessageDialog("You do not have permission to access all folders in this path.\n See your network administrator or try another path.");
                        return(true);
                    }
                    return(false); // Let anything else stop the application.
                });
            }
        }
Exemplo n.º 2
0
 static async public Task Restore <T>()
 {
     if (await DoesFileExistAsync())
     {
         await Windows.System.Threading.ThreadPool.RunAsync((sender)
                                                            => PatternData.RestoreAsync <T>().Wait(), Windows.System.Threading.WorkItemPriority.Normal);
     }
     else
     {
         file = await ApplicationData.Current.LocalFolder.CreateFileAsync(filename);
     }
 }