view api/Objects/SystemStats.cs @ 5:b9346894319c

Fixes #6 - Stop missing data folder being fatal * Add check that directory exists before trying to get file list * Add warning message if directory doesn't exist
author IBBoard <dev@ibboard.co.uk>
date Fri, 26 Dec 2008 12:45:32 +0000
parents 520818033bb6
children 607c3232d689
line wrap: on
line source

using System;
using System.Collections.Generic;

namespace IBBoard.WarFoundry.API.Objects
{
	/// <summary>
	/// Summary description for SystemStats.
	/// </summary>
	public class SystemStats
	{
		private Dictionary<string, StatSlot> stats;
		private string id;

		public SystemStats(string statsID, StatSlot[] statSlots)
		{
			id = statsID;
			stats = new Dictionary<string, StatSlot>();
			
			foreach (StatSlot slot in statSlots)
			{
				slot.SystemStats = this;
				stats[slot.Name] = slot;
			}
		}

		public StatSlot[] StatSlots
		{
			get
			{
				StatSlot[] slots = new StatSlot[stats.Count];
				stats.Values.CopyTo(slots, 0);
				return slots;
			}
		}
		
		public StatSlot this[string key]
		{
			get 
			{
				StatSlot slot = null;
				stats.TryGetValue(key, out slot);
				return slot;
			}
		}
		
        public int SlotCount
        {
            get { return stats.Count; }
        }
		
		public string ID
		{
			get { return id; }
		}
	}
}