Esempio n. 1
0
        public LootFactory(IRepository repository)
        {
            if (repository == null)
            {
                throw new ArgumentNullException("A loot repository must be supplied");
            }

            this.lootCollection = repository.GetLootCollection();
            Count = lootCollection.Loot.Count;
        }
Esempio n. 2
0
        public LootCollection GetLootCollection()
        {
            var fileName       = ConfigurationManager.AppSettings["LootFileName"];
            var lootCollection = new LootCollection();

            try
            {
                var LootData = File.ReadAllText(fileName);
                lootCollection = JsonConvert.DeserializeObject <LootCollection>(LootData);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error occured while trying to load {fileName}. Exception details : {ex}");
            }

            return(lootCollection);
        }