using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace MikuMikuDance.XNA.Forms.Content
{
    /// <summary>
    /// サービスコンテナクラス
    /// </summary>
    class ServiceContainer : IServiceProvider
    {
        Dictionary<Type, object> services = new Dictionary<Type, object>();
        /// <summary>
        /// サービスの追加
        /// </summary>
        /// <typeparam name="T">サービスの型</typeparam>
        /// <param name="service">サービスオブジェクト</param>
        public void AddService<T>(T service)
        {
            services.Add(typeof(T), service);
        }
        #region IServiceProvider メンバ
        /// <summary>
        /// サービスの取得
        /// </summary>
        /// <param name="serviceType">サービスの型</param>
        /// <returns>サービスオブジェクト</returns>
        public object GetService(Type serviceType)
        {
            object service;
            services.TryGetValue(serviceType, out service);
            return service;
        }

        #endregion
    }
}
