public static IUnityContainer CreateContainer(IInterceptor[] globalInterceptors) { IUnityContainer unityContainer = new UnityContainer(); ByConventionRegistrator.RegisterTypesByConvention(unityContainer); return(InterceptionHelper.InterceptContainer(unityContainer, globalInterceptors)); }
/// <summary> /// A partir de la interfaz T obtenemos todas las clases que la implementan /// de la lista de assemblies donde se buscan registros por convención /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public static List <Type> GetAutoNamedTypesFor <T>() { return(ByConventionRegistrator.GetAssembilesWithConventionRegistration() .SelectMany(s => { Type[] types; try { types = s.GetTypes(); } catch (Exception ex) { if (ex is System.Reflection.ReflectionTypeLoadException) { var typeLoadException = ex as ReflectionTypeLoadException; var loaderExceptions = typeLoadException.LoaderExceptions; var errorMsg = typeLoadException.ToString() + Environment.NewLine + "loaderException: " + string.Join("loaderException: ", loaderExceptions.Select(e => e.ToString()).ToList()); throw new ApplicationException(errorMsg); } throw; } return types; }).Where(IsRegistrable <T>).ToList()); }