Esempio n. 1
0
        /// <summary>
        /// Factory method
        /// </summary>
        public static Dispatcher Create(Func <DispatcherConfiguration, DispatcherConfiguration> configurationAction)
        {
            var config = new DispatcherConfiguration();

            configurationAction(config);
            return(new Dispatcher(config));
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.Object"/> class.
        /// </summary>
        public Dispatcher(DispatcherConfiguration configuration)
        {
            if (configuration.ServiceLocator == null)
            {
                throw new ArgumentException("Unity Container is not registered for distributor.");
            }

            if (configuration.DispatcherHandlerRegistry == null)
            {
                throw new ArgumentException("Dispatcher Handler Registry is null in distributor.");
            }

            _serviceLocator = configuration.ServiceLocator;
            _registry       = configuration.DispatcherHandlerRegistry;
            _maxRetries     = configuration.NumberOfRetries;

            // order handlers
            _registry.InsureOrderOfHandlers(configuration.Order);
        }
 public static DispatcherConfiguration SetServiceLocator(this DispatcherConfiguration configuration, IServiceLocator container)
 {
     configuration.ServiceLocator = container;
     return(configuration);
 }
 public static DispatcherConfiguration SetOrder(this DispatcherConfiguration configuration, params Type[] types)
 {
     configuration.Order = types.ToList();
     return(configuration);
 }
 public static DispatcherConfiguration SetHandlerMarkerInterface(this DispatcherConfiguration configuration, Type markerInterface)
 {
     configuration.MessageHandlerMarkerInterface = markerInterface;
     return(configuration);
 }
 public static DispatcherConfiguration AddHandlers(this DispatcherConfiguration configuration, Assembly assembly)
 {
     return(AddHandlers(configuration, assembly, new string[] { }));
 }
 public static DispatcherConfiguration AddHandlers(this DispatcherConfiguration configuration, Assembly assembly, String[] namespaces)
 {
     configuration.DispatcherHandlerRegistry.Register(assembly, namespaces);
     return(configuration);
 }
 public static DispatcherConfiguration SetMaxRetries(this DispatcherConfiguration configuration, Int32 maxRetries)
 {
     configuration.NumberOfRetries = maxRetries;
     return(configuration);
 }