public void Register(IContainerManager containerManager, CMS.Common.Runtime.ITypeFinder typeFinder)
        {
            var assemblies = typeFinder.GetAssemblies()
                                       .Where(x => !IsIgnoredAssembly(x))
                                       .ToList();

            // Handler Registry
            var handlerRegistry = new DefaultEventHandlerRegistry();
            handlerRegistry.RegisterAssemblies(assemblies);
            containerManager.AddComponentInstance<IEventHandlerRegistry>(handlerRegistry);

            // Event Registry
            var eventRegistry = new DefaultEventRegistry();
            eventRegistry.RegisterAssemblies(assemblies);
            containerManager.AddComponentInstance<IEventRegistry>(eventRegistry);

            // Event Dispatcher
            var eventDispatcher = new DefaultEventDispatcher(handlerRegistry);
            containerManager.AddComponentInstance<IEventDispatcher>(eventDispatcher);
        }
Esempio n. 2
0
        public void Register(IContainerManager containerManager, CMS.Common.Runtime.ITypeFinder typeFinder)
        {
            var assemblies = typeFinder.GetAssemblies()
                                       .Where(x => !IsIgnoredAssembly(x))
                                       .ToList();

            foreach (var assembly in assemblies)
            {
                foreach (var handlerType in assembly.GetTypes())
                {
                    if (!handlerType.IsClass || handlerType.IsAbstract || handlerType.IsGenericType)
                    {
                        continue;
                    }

                    foreach (var eventType in GetHandledEventTypes(handlerType))
                    {
                        Event.Listen(eventType, handlerType);
                    }
                }
            }
        }