Exemple #1
0
        public static List <Card> LoadCollection(Account account)
        {
            List <Card> lstRet = new List <Card>();

            try
            {
                string strPath = DustUtilityPlugin.GetFullFileName(account, CollectionString);

                if (File.Exists(strPath))
                {
                    List <CachedCard> lstCachedCards = FileManager.Load <List <CachedCard> >(strPath);

                    for (int i = 0; i < lstCachedCards.Count; i++)
                    {
                        CachedCard cachedCard = lstCachedCards[i];

                        lstRet.Add(new Card(cachedCard.Id, cachedCard.Count, cachedCard.IsGolden));
                    }
                }
                else
                {
                }
            }
            catch (System.Exception ex)
            {
                Log.WriteLine($"Exception occured while loading collection: {ex}", LogType.Error);
            }

            return(lstRet);
        }
        public static List <Card> LoadCollection(Account account, string strType = CollectionString)
        {
            List <Card> lstRet = new List <Card>();

            string strPath = DustUtilityPlugin.GetFullFileName(account, strType);

            if (File.Exists(strPath))
            {
                List <CachedCard> lstCachedCards = new List <CachedCard>();

                using (StreamReader reader = new StreamReader(strPath))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(List <CachedCard>));

                    lstCachedCards = (List <CachedCard>)serializer.Deserialize(reader);
                }

                for (int i = 0; i < lstCachedCards.Count; i++)
                {
                    CachedCard cachedCard = lstCachedCards[i];

                    lstRet.Add(new Card(cachedCard.Id, cachedCard.Count, cachedCard.IsGolden));
                }
            }
            else
            {
            }

            return(lstRet);
        }