All pastes #244797 Raw Edit

Someone

public text v1 · immutable
#244797 ·published 2006-11-10 05:23 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Text;

namespace FlatRedBall
{
    class FlatRedBallServices
    {

        private static Dictionary<Type, object> mPool;

        static FlatRedBallServices()
        {
            mPool = new Dictionary<Type, object>();
        }

        public static void RegisterService(Type t, object service)
        {
            Type t = service.GetType();
            RegisterService(t, service);
        }

        public static void RegisterService<T>(object service)
        {
            RegisterService(typeof(T), service);
        }

        public static void RegisterService(Type t, object service)
        {
            if (!mPool.ContainsKey(t))
            {
                mPool.Add(t, service);
            }
        }

        public static T GetService<T>()
        {
            return (T)mPool[typeof(T)];
        }
    }
}