private static void InitializeIoc() { if (s_iocRegistrar == null) { // Initialize default dependency injection engine // Scan for internal assemblies only s_iocRegistrar = new DefaultRegistrar(); Assembly[] loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies(); Type iocModuleInterface = typeof(IModule); s_iocRegistrar.RegisterModule <TfxModule>(); foreach (Assembly assembly in loadedAssemblies) { if (!assembly.FullName.StartsWith("Tfx.")) { continue; } IEnumerable <Type> assemblyIocModules = assembly.GetTypes() .Where(x => { return(iocModuleInterface.IsAssignableFrom(x)); }); foreach (Type iocModule in assemblyIocModules) { s_iocRegistrar.RegisterModule(iocModule); } } } }