private IEnumerable<PollProcessorEndpoint> RegisterEndPoint(IUnityContainer container,
            PollProcessorEndpoint endpoint)
        {
            if (endpoint.SinglePolling && endpoint.Workers > 1)
            {
                logger.WarnFormat("{0} - Cannot have multiple workers for a Single Polling. Changing workers to 1",
                    endpoint.Name);
                endpoint.Workers = 1;
            }

            for (var index = 1; index < endpoint.Workers; index++)
            {
                var newEndPoint = new PollProcessorEndpoint
                {
                    Workers = 1,
                    SinglePolling = true,
                    Handler = endpoint.Handler,
                    IntervalSecs = endpoint.IntervalSecs,
                    Name = string.Format("{0}_{1}", endpoint.Name, index)
                };
                container.RegisterPollProcessor(newEndPoint);
                yield return newEndPoint;
            }

            endpoint.Workers = 1;

            container.RegisterPollProcessor(endpoint);
            yield return endpoint;
        }
        public static void RegisterPollProcessor(this IUnityContainer container, PollProcessorEndpoint endpoint)
        {
            endpoint.Validate();

            container.RegisterInstance(endpoint.Name, endpoint);
            container.RegisterType(typeof(IPoller), endpoint.Handler, endpoint.Name);
            container.RegisterType(
                typeof(IPollProcessor),
                typeof(PollProcessor),
                endpoint.Name,
                new PerResolveLifetimeManager(),
                new InjectionConstructor(
                    new ResolvedParameter<PollProcessorEndpoint>(endpoint.Name),
                    new ResolvedParameter<IPoller>(endpoint.Name)));
        }
        public PollProcessor(PollProcessorEndpoint endpoint, IPoller poller)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException("endpoint");
            }

            if (poller == null)
            {
                throw new ArgumentNullException("poller");
            }

            this.Endpoint = endpoint;
            this.Poller = poller;

            this.timer = new Timer(this.Endpoint.IntervalSecs * 1000) { AutoReset = true };
            this.timer.Elapsed += this.TimerElapsed;
        }
Example #4
0
        public PollProcessor(PollProcessorEndpoint endpoint, IPoller poller)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException("endpoint");
            }

            if (poller == null)
            {
                throw new ArgumentNullException("poller");
            }

            this.Endpoint = endpoint;
            this.Poller   = poller;

            this.timer = new Timer(this.Endpoint.IntervalSecs * 1000)
            {
                AutoReset = true
            };
            this.timer.Elapsed += this.TimerElapsed;
        }