using System;
using System.Collections.Generic;
using Interfaces;
using Ninject;

namespace RaceLapTimer.Extensions
{
    class ContainerHelper : IContainerHelper
    {
        private readonly IKernel _container;
        public ContainerHelper(IKernel container)
        {
            _container = container;
        }

        public void RegisterType(Type typeToBindTo, Type typeBeingBound, string uniqueName)
        {
            if (string.IsNullOrEmpty(uniqueName))
            {
                _container.Bind(typeToBindTo).To(typeBeingBound);
            }
            else
            {
                _container.Bind(typeToBindTo).To(typeBeingBound).Named(uniqueName);
            }
        }

        public T Get<T>()
        {
            return _container.Get<T>();
        }

        public IEnumerable<T> GetAll<T>()
        {
            return _container.GetAll<T>();
        }
    }
}