Esempio n. 1
0
        public async Task <DeckObservableDict <D> > GetListFromJsonAsync(string jsonData)
        {
            bool doRedo = RedoList();
            CustomBasicList <int> thisList = await js.DeserializeObjectAsync <CustomBasicList <int> >(jsonData);

            CustomBasicList <D> tempList = new CustomBasicList <D>();

            if (doRedo == true)
            {
                thisList.ForEach(Items =>
                {
                    D thisD = new D();
                    _beforePopulate !.Invoke(thisD); //sometimes something has to be done before the card can be populated.
                    thisD.Populate(Items);
                    tempList.Add(thisD);
                });
                _privateDict.AddRange(tempList, System.Collections.Specialized.NotifyCollectionChangedAction.Add);
                return(new DeckObservableDict <D>(tempList));
            }
            if (_privateDict.Count == thisList.Count)
            {
                FixObjects();
                DeckRegularDict <D> newTemp = new DeckRegularDict <D>(_privateDict);
                thisList.ForEach(Items =>
                {
                    tempList.Add(newTemp.GetSpecificItem(Items));
                });
                _privateDict.ReplaceRange(tempList);
                return(new DeckObservableDict <D>(tempList));
            }
            UnlinkObjects();
            thisList.ForEach(items =>
            {
                D thisD          = _privateDict.GetSpecificItem(items);
                thisD.Visible    = true;
                thisD.IsEnabled  = true;
                thisD.IsUnknown  = false;
                thisD.IsSelected = false;
                thisD.Drew       = false;
                tempList.Add(thisD);
            });
            return(new DeckObservableDict <D>(tempList));
        }