Esempio n. 1
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            //全局服务注册表
            ServiceBusSection serviceBusSection = (ServiceBusSection)ConfigurationManager.GetSection("serviceBus");

            container.Register(Component.For <ServiceBusRegistry>().LifestyleSingleton());
            var busRegistry = container.Resolve <ServiceBusRegistry>();

            this.serviceBusRegistry = busRegistry.Initital(serviceBusSection);

            //ServiceBus初始化
            container.Register(
                Component.For <ServiceBus>().UsingFactoryMethod(() =>
            {
                ServiceBus.Instance.IocResolver        = iocResolver;
                ServiceBus.Instance.Serializer         = container.Resolve <Serialization.ISerializer>();
                ServiceBus.Instance.Logger             = iocResolver.Resolve <ILogger>();
                ServiceBus.Instance.PerformanceCounter = iocResolver.Resolve <WindPerformanceCounter>();
                return(ServiceBus.Instance);
            }).LifestyleSingleton());
            this.serviceBus = container.Resolve <ServiceBus>();

            //获取服务程序集模块
            var moduleManager = iocResolver.Resolve <IWindModuleManager>();

            foreach (var windModuleInfo in moduleManager.Modules)
            {
                var serviceAssembAttr = ReflectionHelper.GetSingleAttributeOrDefault <ServiceAssemblyNameAttribute>(windModuleInfo.Type);
                if (serviceAssembAttr != null)
                {
                    string serviceAssemblyName = serviceAssembAttr.ServiceAssemblyName;
                    serviceAssemblyDic.Add(serviceAssemblyName, windModuleInfo.Assembly);

                    // 尝试注册未在配置文件中配置的本地程序集!!!
                    busRegistry.RegisterServiceAssembly(serviceAssemblyName);
                }
            }

            container.Kernel.ComponentRegistered += Kernel_ComponentRegistered;
        }
Esempio n. 2
0
        //TODO: [事件类型, 事件消费者]
        //private readonly ConcurrentDictionary<Type, List<IServiceEventHandlerFactory>> _eventHandlerFactories;

        static ServiceBus()
        {
            Instance = new ServiceBus();
        }