コード例 #1
0
        static void RegistrarTodosOsModulos(Container container)
        {
            var assemblies = new AssembliesItix();

            var reflectionUtils = new ReflectionUtils();

            var containerRegister = reflectionUtils
                                    .AllImplementationsFrom <IContainerRegister>(assemblies.GetAssemblies())
                                    .Select(type => (Activator.CreateInstance(type) as IContainerRegister))
                                    .Select(register => { register.Assemblies = assemblies; return(register); })
                                    .ToList();


            containerRegister.ForEach(x => x.Register(container));


            containerRegister.ForEach(x => x.OnRegisterCompleted(container));
        }
コード例 #2
0
        static void RegistrarTodosOsModulos(Container container)
        {
            var assemblies = new AssembliesItix();


            var type  = typeof(IContainerRegister);
            var types = assemblies.GetAssemblies()
                        .SelectMany(s => s.GetTypes())
                        .Where(p => type.IsAssignableFrom(p) && p.IsClass && !p.IsAbstract);


            foreach (var item in types)
            {
                var containerRegister = (Activator.CreateInstance(item) as IContainerRegister);
                containerRegister.Assemblies = assemblies;

                containerRegister.Register(container);
            }
        }