using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;

namespace WebApplication1.Repositories.ArticleCommerceRepository {
  public class ArticleCommerceRepositoryFactory {
    private static System.Reflection.ConstructorInfo ArticleCommerceRepositoryCtor;
    public static ArticleCommerceRepositoryBase Instancier() {
      if( ArticleCommerceRepositoryCtor == null ) {
        string nomDuType = ConfigurationManager.AppSettings["ArticleCommerceRepository"];
        ArticleCommerceRepositoryCtor =
          AppDomain.CurrentDomain
          .GetAssemblies()
          .SelectMany( asm => asm.GetTypes() )
          .Where( t => t.FullName == nomDuType )
          .Select( t => t.GetConstructor( new Type[0] ) )
          .First();
        }
      return (ArticleCommerceRepositoryBase)ArticleCommerceRepositoryCtor.Invoke( null );
    }
  }
}