Exemplo 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));
        }
        /// <summary>
        /// Configure dispatcher
        /// </summary>
        public static ServiceBusConfiguration Dispatcher(this ServiceBusConfiguration configuration, Func<DispatcherConfiguration, DispatcherConfiguration> configurationAction)
        {
            var dispatcherConfiguration = new DispatcherConfiguration();
            dispatcherConfiguration.SetServiceLocator(configuration.ServiceLocator);
            configurationAction(dispatcherConfiguration);

            configuration.DispatcherConfiguration = dispatcherConfiguration;
            return configuration;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.Object"/> class.
        /// </summary>
        public ServiceBusConfiguration()
        {
            EndpointsMapping = new EndpointsMapping();
            DispatcherConfiguration = new DispatcherConfiguration();

            // Default name of service bus
            Name = "Unnamed";

            // By default we are using one thread
            NumberOfWorkerThreads = 1;
        }
Exemplo n.º 4
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.MaxRetries;

            // order handlers 
            _registry.InsureOrderOfHandlers(configuration.Order);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
 public static DispatcherConfiguration SetServiceLocator(this DispatcherConfiguration configuration, IServiceLocator container)
 {
     configuration.ServiceLocator = container;
     return(configuration);
 }
Exemplo n.º 7
0
 public static DispatcherConfiguration SetOrder(this DispatcherConfiguration configuration, params Type[] types)
 {
     configuration.Order = types.ToList();
     return(configuration);
 }
Exemplo n.º 8
0
 public static DispatcherConfiguration SetHandlerMarkerInterface(this DispatcherConfiguration configuration, Type markerInterface)
 {
     configuration.MessageHandlerMarkerInterface = markerInterface;
     return(configuration);
 }
Exemplo n.º 9
0
 public static DispatcherConfiguration AddHandlers(this DispatcherConfiguration configuration, Assembly assembly)
 {
     return(AddHandlers(configuration, assembly, new string[] { }));
 }
Exemplo n.º 10
0
 public static DispatcherConfiguration AddInterceptor(this DispatcherConfiguration configuration, Type interceptor)
 {
     configuration.DispatcherHandlerRegistry.AddInterceptor(interceptor);
     return(configuration);
 }
Exemplo n.º 11
0
 public static DispatcherConfiguration AddHandlers(this DispatcherConfiguration configuration, Assembly assembly, String[] namespaces)
 {
     configuration.DispatcherHandlerRegistry.Register(assembly, namespaces);
     return(configuration);
 }
Exemplo n.º 12
0
 public static DispatcherConfiguration SetMaxRetries(this DispatcherConfiguration configuration, Int32 maxRetries)
 {
     configuration.NumberOfRetries = maxRetries;
     return(configuration);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Factory method
 /// </summary>
 public static Dispatcher Create(Func<DispatcherConfiguration, DispatcherConfiguration> configurationAction)
 {
     var config = new DispatcherConfiguration();
     configurationAction(config);
     return new Dispatcher(config);
 }