public async Task SaveAppInfo(SavedAppInfo appInfo)
        {
            Exception ex = null;
            this.savedAppInfo = appInfo;
            try
            {
                var file = await ApplicationData.Current.LocalFolder.CreateFileAsync(SavedAppsFileName, CreationCollisionOption.ReplaceExisting);
                using (var stream = await file.OpenStreamForWriteAsync())
                {
                    DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(SavedAppInfo));
                    dcjs.WriteObject(stream, appInfo);
                }
            }
            catch (Exception e)
            {
                ex = e;
            }

            if (ex != null)
            {
                await new MessageDialog(
                    string.Format("{0}: {1}", ex.GetType().FullName, ex.Message),
                    "Error saving app info").ShowAsync();
            }
        }
Exemple #2
0
        public async Task SaveAppInfo(SavedAppInfo appInfo)
        {
            Exception ex = null;

            this.savedAppInfo = appInfo;
            try
            {
                var file = await ApplicationData.Current.LocalFolder.CreateFileAsync(SavedAppsFileName, CreationCollisionOption.ReplaceExisting);

                using (var stream = await file.OpenStreamForWriteAsync())
                {
                    DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(SavedAppInfo));
                    dcjs.WriteObject(stream, appInfo);
                }
            }
            catch (Exception e)
            {
                ex = e;
            }

            if (ex != null)
            {
                await new MessageDialog(
                    string.Format("{0}: {1}", ex.GetType().FullName, ex.Message),
                    "Error saving app info").ShowAsync();
            }
        }
        public async Task <SavedAppInfo> GetSavedAppInfo()
        {
            if (savedAppInfo == null)
            {
                try
                {
                    using (var stream = await Util.OpenAppSettingsForRead(SavedAppsFileName))
                    {
                        DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(SavedAppInfo));
                        savedAppInfo = (SavedAppInfo)dcjs.ReadObject(stream);
                    }
                }
                catch (Exception)
                {
                    // Cannot retrieve saved info
                    return(new SavedAppInfo());
                }
            }

            return(savedAppInfo);
        }
        public async Task<SavedAppInfo> GetSavedAppInfo()
        {
            if (savedAppInfo == null)
            {
                try
                {
                    using (var stream = await Util.OpenAppSettingsForRead(SavedAppsFileName))
                    {
                        DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(SavedAppInfo));
                        savedAppInfo = (SavedAppInfo)dcjs.ReadObject(stream);
                    }
                }
                catch (Exception)
                {
                    // Cannot retrieve saved info
                    return new SavedAppInfo();
                }
            }

            return savedAppInfo;
        }
        public async Task<SavedAppInfo> GetSavedAppInfo()
        {
            if (savedAppInfo == null)
            {
                try
                {
                    var file = await ApplicationData.Current.LocalFolder.GetFileAsync(SavedAppsFileName);
                    using (var stream = await file.OpenStreamForReadAsync())
                    {
                        DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(SavedAppInfo));
                        savedAppInfo = (SavedAppInfo)dcjs.ReadObject(stream);
                    }
                }
                catch (Exception)
                {
                    // Cannot retrieve saved info
                    return new SavedAppInfo();
                }
            }

            return savedAppInfo;
        }
Exemple #6
0
        public async Task <SavedAppInfo> GetSavedAppInfo()
        {
            if (savedAppInfo == null)
            {
                try
                {
                    var file = await ApplicationData.Current.LocalFolder.GetFileAsync(SavedAppsFileName);

                    using (var stream = await file.OpenStreamForReadAsync())
                    {
                        DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(SavedAppInfo));
                        savedAppInfo = (SavedAppInfo)dcjs.ReadObject(stream);
                    }
                }
                catch (Exception)
                {
                    // Cannot retrieve saved info
                    return(new SavedAppInfo());
                }
            }

            return(savedAppInfo);
        }
        public async Task SaveAppInfo(SavedAppInfo appInfo)
        {
            Exception ex = null;
            this.savedAppInfo = appInfo;
            try
            {
                using (var stream = await Util.OpenAppSettingsForWrite(SavedAppsFileName))
                {
                    DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(SavedAppInfo));
                    dcjs.WriteObject(stream, appInfo);
                }
            }
            catch (Exception e)
            {
                ex = e;
            }

            if (ex != null)
            {
                string errorText = string.Format("{0}: {1}", ex.GetType().FullName, ex.Message);
                await Util.MessageBox(errorText, "Error saving app info");
            }
        }
        public async Task SaveAppInfo(SavedAppInfo appInfo)
        {
            Exception ex = null;

            this.savedAppInfo = appInfo;
            try
            {
                using (var stream = await Util.OpenAppSettingsForWrite(SavedAppsFileName))
                {
                    DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(SavedAppInfo));
                    dcjs.WriteObject(stream, appInfo);
                }
            }
            catch (Exception e)
            {
                ex = e;
            }

            if (ex != null)
            {
                string errorText = string.Format("{0}: {1}", ex.GetType().FullName, ex.Message);
                await Util.MessageBox(errorText, "Error saving app info");
            }
        }