Пример #1
0
        private static IWindsorInstaller ApplicationAssemblies(Assembly rootAssembly, InstallerFactory installerFactory)
        {
            var assemblies = new HashSet <Assembly>(ReflectionUtil.GetApplicationAssemblies(rootAssembly));
            var installer  = new CompositeInstaller();

            foreach (var assembly in assemblies)
            {
                installer.Add(Instance(assembly, installerFactory));
            }
            return(installer);
        }
Пример #2
0
        /// <summary>
        /// Scans assemblies in directory specified by <paramref name = "filter" /> for types implementing <see cref = "IWindsorInstaller" />, instantiates using given <see cref = "InstallerFactory" /> and
        /// returns so that <see cref = "IWindsorContainer.Install" /> can install them.
        /// </summary>
        /// <param name = "filter"> </param>
        /// <param name = "installerFactory"> </param>
        /// <returns> </returns>
        public static IWindsorInstaller InDirectory(AssemblyFilter filter, InstallerFactory installerFactory)
        {
            var assemblies = new HashSet <Assembly>(ReflectionUtil.GetAssemblies(filter));
            var installer  = new CompositeInstaller();

            foreach (var assembly in assemblies)
            {
                installer.Add(Instance(assembly, installerFactory));
            }
            return(installer);
        }
Пример #3
0
        /// <summary>
        /// Search for installers in assemblies referenced by the specified assembly (use for ASP.NET, e.g. 
        /// in Application_Start)
        /// </summary>
        /// <param name="rootAssembly"></param>
        /// <returns>Composite installer with all referenced assemblies</returns>
        public static IWindsorInstaller Referenced(Assembly rootAssembly)
        {
            rootAssembly = rootAssembly ?? Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly() ?? Assembly.GetExecutingAssembly();
            Dictionary<string, Assembly> assemblies = new Dictionary<string, Assembly>();
            GetReferencedAssemblies(assemblies, rootAssembly);

            CompositeInstaller installer = new CompositeInstaller();
            foreach (Assembly assembly in assemblies.Values)
            {
                installer.Add(FromAssembly.Instance(assembly));
            }
            return installer;
        }