예제 #1
0
        public async Task <AsyncVoidMethodBuilder> LoadLocalDataAsync()
        {
            if (App.first)
            {
                AllGroups  = new ObservableCollection <QuoteGroup>();
                _quoteList = new HashSet <QuoteItem>();
                return(AsyncVoidMethodBuilder.Create());
            }

            QuoteItem[] list = null;
            try
            {
                list = await ObjectPersister.Load <QuoteItem[]>("data_quotes", ObjectPersisterLocation.Local);
            }
            catch (Exception e)
            {
                Log("LoadLocalDataAsync", e.Message);
                ThinkDataSource.statusLoad = ThinkDataSource.XMLCorruptedError;
                list = null;
            }
            finally
            {
                //
                lock (_lockerQuoteList)
                {
                    if (list == null)
                    {
                        _quoteList = new HashSet <QuoteItem>();
                    }
                    else
                    {
                        _quoteList = new HashSet <QuoteItem>(list);
                    }

                    AllGroups = new ObservableCollection <QuoteGroup>();

                    MountGroups();
                }
            }
            return(AsyncVoidMethodBuilder.Create());
        }