Exemplo n.º 1
0
        /// <summary>
        /// 从储存反序列化所有数据
        /// </summary>
        /// <returns></returns>
        private async Task RestoreData(bool restoreMainList)
        {
            try
            {
                if (restoreMainList)
                {
                    MyToDos = await SerializerHelper.DeserializerFromJsonByFileName <ObservableCollection <ToDo> >(SerializerFileNames.ToDoFileName);

                    CurrentDisplayToDos = MyToDos;
                    Messenger.Default.Send(new GenericMessage <ObservableCollection <ToDo> >(MyToDos), MessengerTokens.UpdateTile);
                }
                var oriList = await SerializerHelper.DeserializerFromJsonByFileName <ObservableCollection <ToDo> >(SerializerFileNames.DeletedFileName);

                var deletedToDos = from todo in oriList where todo != null select todo;
                DeletedToDos = new ObservableCollection <ToDo>();
                deletedToDos.ToList().ForEach(s => DeletedToDos.Add(s));
                LOAD_ONCE = true;
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }