﻿using Autofac;
using System.Reflection;
using PixelatedDesigns.Arena.Providers;
using PixelatedDesigns.Arena.Common.Interfaces;
using PixelatedDesigns.Arena.Composition.Extensions;

namespace PixelatedDesigns.Arena.Composition.Installers
{
  class ProvidersInstaller : IInstaller
  {
	public void Install(ContainerBuilder container)
	{
	  var providerAssembly = typeof(BaseProvider<,>).GetTypeInfo().Assembly;

	  container
		.RegisterAssemblyTypes(providerAssembly)
		.Where(t => t.IsAssignableToGenericType(typeof(ICrudProvider<>)))
		.AsSelf()
		.SingleInstance();
	}
  }
}
