public static IReadOnlyCollection <object> RejectAll(this IHandlerRegistry registry) { return(new ReadOnlyCollection <object>(new List <object> { new AlwaysRejectMessageHandler() })); }
public QueryDocument(IHandlerRegistry handlerRegistry, Query query) { InitializeComponent(); _objectSelectionHandler = handlerRegistry.GetHandler <IObjectSelectionHandler>(); _syntaxEditorClipboardHandler = new SyntaxEditorClipboardHandler(syntaxEditor); _syntaxEditorUndoRedoHandler = new SyntaxEditorUndoRedoHandler(syntaxEditor); _resultsDataGridViewClipboardHandler = new ResultsDataGridViewClipboardHandler(resultsDataGridView); _errorListClipboardHandler = new ErrorListClipboardHandler(errorsListView); _query = query; _actiproLink = new ActiproLink(components); _actiproLink.SyntaxEditor = syntaxEditor; _actiproLink.Evaluatable = _query; _queryBrowser = new QueryBrowser(handlerRegistry, _query); resultsDataGridView.AllowUserToResizeRows = false; resultsDataGridView.BackgroundColor = System.Drawing.SystemColors.Window; resultsDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; resultsDataGridView.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; resultsDataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; resultsDataGridView.GridColor = System.Drawing.SystemColors.ActiveBorder; resultsDataGridView.RowHeadersVisible = false; resultsDataGridView.DataError += delegate { }; syntaxEditor.Text = _query.Text; ClearStatusPanel(); }
public DefaultEventDispatcher(IHandlerRegistry handlerRegistry, IHandlerInvoker handlerInvoker) { Require.NotNull(handlerRegistry, "handlerRegistry"); Require.NotNull(handlerInvoker, "handlerInvoker"); _handlerRegistry = handlerRegistry; _handlerInvoker = handlerInvoker; }
public void RegisterHandlers(IHandlerRegistry handlerRegistry) { foreach (var hi in handlers.Value) { handlerRegistry.Register(hi.MessageType, new HandlerInfo(hi.HandlerType, hi.MessageType, hi.ProcessCode, hi.MethodInfo)); } }
public static IHandlerRegistry On <T>(this IHandlerRegistry registry, IRpcHandler <T> handler) where T : IRpcRequestMessage { if (handler == null) { throw new ArgumentNullException("handler"); } return(registry.On <T>(handler.HandleAsync)); }
public static IHandlerRegistry On <T>(this IHandlerRegistry registry, Func <T, Action <object>, Task> handler) { if (handler == null) { throw new ArgumentNullException("handler"); } return(registry.On(typeof(T), (x, a) => handler((T)x, a))); }
public void Init(ITypesProvider typesProvider) { IHandlerRegistry handlerRegistry = typesProvider.Resolve <IHandlerRegistry>(); handlerRegistry.RegisterHandler <GetDeviceDefinitionsQuery, GetDeviceDefinitionsQueryHandler>(); handlerRegistry.RegisterHandler <UpdateDeviceDefinitionCommand, UpdateDeviceDefinitionCommandHandler>(); handlerRegistry.RegisterHandler <GetStoreSnapshotQuery, GetStoreSnapshotQueryHandler>(); handlerRegistry.RegisterHandler <UploadSnapshotCommand, UploadSnapshotCommandHandler>(); }
public QueryBrowser(IHandlerRegistry handlerRegistry, Evaluatable evaluatable) { InitializeComponent(); _handlerRegistry = handlerRegistry; _evaluatable = evaluatable; evaluatableBrowser.Evaluatable = evaluatable; evaluatableBrowser.SelectedItemChanged += evaluatableBrowser_SelectedItemChanged; Application.Idle += Application_OnIdle; }
public static IHandlerRegistry On(this IHandlerRegistry registry, Type type, Func <object, Task> handler) { if (type == null) { throw new ArgumentNullException("type"); } if (handler == null) { throw new ArgumentNullException("handler"); } return(registry.On(type, (x, a) => handler(x))); }
private async Task <bool> CallHandlers(IHandlerRegistry handlers, Type type, object message, Action <object> action) { var result = true; var errorHandler = handlers.FindErrorHandler(type); var typeHandlers = handlers.FindHandler(type); if (typeHandlers != null) { foreach (var handler in typeHandlers) { var hresult = true; var errorMessage = "No error."; try { await handler(message, action); } catch (Exception ex) { errorMessage = string.Format("Message handler failed: {0}", ex.Message); _logger.Error("Message handler exception:", ex); hresult = false; } if (!hresult && errorHandler != null) { try { await errorHandler(errorMessage, action); } catch (Exception ex) { _logger.Error("Error handler exception:", ex); } } result = result && hresult; } } else { _logger.Error("Handler for type '{0}' not found. Dropping message.", type.Name); result = false; } return(result); }
/// <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("Service Locator is not registered for distributor."); _registry = configuration.Builder.BuildHandlerRegistry(); _serviceLocator = configuration.ServiceLocator; /* if (configuration.DispatcherHandlerRegistry == null) throw new ArgumentException("Dispatcher Handler Registry is null in distributor."); _registry = configuration.DispatcherHandlerRegistry; _maxRetries = configuration.MaxRetries; // order handlers _registry.InsureOrderOfHandlers(configuration.Order);*/ }
/// <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("Service Locator is not registered for distributor."); } _registry = configuration.Builder.BuildHandlerRegistry(); _serviceLocator = configuration.ServiceLocator; /* * if (configuration.DispatcherHandlerRegistry == null) * throw new ArgumentException("Dispatcher Handler Registry is null in distributor."); * * * _registry = configuration.DispatcherHandlerRegistry; * _maxRetries = configuration.MaxRetries; * * // order handlers * _registry.InsureOrderOfHandlers(configuration.Order);*/ }
/// <summary> /// Initializes a new interpreter and discovers methods marked /// with <see cref="CommandHandlerAttribute"/> attribute. /// </summary> protected CommandInterpreter() { var interpreters = new Dictionary <int, CommandHandler>(); var formatters = new Dictionary <Type, FormatterInfo>(); const BindingFlags publicInstanceMethod = BindingFlags.Public | BindingFlags.Instance; foreach (var method in GetType().GetMethods(publicInstanceMethod)) { var handlerAttr = method.GetCustomAttribute <CommandHandlerAttribute>(); if (handlerAttr is not null && method.ReturnType == typeof(ValueTask)) { var parameters = method.GetParameterTypes(); if (GetLength(parameters) != 2 || !parameters[0].IsValueType || parameters[1] != typeof(CancellationToken)) { continue; } var commandType = parameters[0]; var commandAttr = commandType.GetCustomAttribute <CommandAttribute>(); if (commandAttr is null || commandAttr.Formatter is null) { continue; } var formatter = new FormatterInfo(commandAttr); if (formatter.IsEmpty) { continue; } var interpreter = Delegate.CreateDelegate(typeof(Func <, ,>).MakeGenericType(commandType, typeof(CancellationToken), typeof(ValueTask)), method.IsStatic ? null : this, method); interpreters.Add(commandAttr.Id, Cast <CommandHandler>(Activator.CreateInstance(typeof(CommandHandler <>).MakeGenericType(commandType), formatter, interpreter))); formatters.Add(commandType, formatter); } } this.interpreters = CreateRegistry(interpreters); interpreters.Clear(); formatters.TrimExcess(); this.formatters = formatters; }
public void Register(IHandlerRegistry <TAgg, TId, TState> registry) { registry.Register(this); }
public MessageUnit Use(IHandlerRegistry registry) { this.registry = registry; return this; }
public IncomingPipelineFactory(IHandlerRegistry registry) { this.registry = registry; }
public UnitIncomingPipelineFactory(IHandlerRegistry registry, ICollection<LogicalMessage> incoming, ICollection<TransportMessage> deadLetter) { this.incoming = incoming; this.deadLetter = deadLetter; this.registry = registry; }
public static IEnumerable <IEventHandler <TEvent> > GetEventHandlers <TEvent>(this IHandlerRegistry handlerRegistry) where TEvent : IEvent => handlerRegistry.GetEventHandlers(typeof(TEvent)).Cast <IEventHandler <TEvent> >();
public UnitIncomingPipelineFactory(IHandlerRegistry registry, ICollection<LogicalMessage> incoming) { this.incoming = incoming; this.registry = registry; }
internal InterpretingTransformation(int id, IHandlerRegistry registry) { this.handler = registry.TryGetValue(id, out var handler) ? handler : throw new UnknownCommandException(id); this.id = id; }
public static ICommandHandler <TCommand> GetCommandHandler <TCommand>(this IHandlerRegistry handlerRegistry) where TCommand : ICommand => (ICommandHandler <TCommand>)handlerRegistry.GetCommandHandler(typeof(TCommand));
public static IReadOnlyCollection <IHandleMessageAsync <TMessage> > ConsumeWith <TMessage>(this IHandlerRegistry registry, params IHandleMessageAsync <TMessage>[] handlers) { return(new ReadOnlyCollection <IHandleMessageAsync <TMessage> >(handlers.ToList())); }
public static IEnumerable <ICommandHandlerWrapper <TCommand> > GetCommandHandlerWrappers <TCommand>(this IHandlerRegistry handlerRegistry) where TCommand : ICommand => handlerRegistry.GetCommandHandlerWrappers(typeof(TCommand)).Cast <ICommandHandlerWrapper <TCommand> >();
public static IQueryHandler <TQuery, TResult> GetQueryHandler <TQuery, TResult>(this IHandlerRegistry handlerRegistry) where TQuery : IQuery <TResult> => (IQueryHandler <TQuery, TResult>)handlerRegistry.GetQueryHandler(typeof(TQuery), typeof(TResult));
public UnitIncomingPipelineFactory(IHandlerRegistry registry, ICollection <LogicalMessage> incoming, ICollection <TransportMessage> deadLetter) { this.incoming = incoming; this.deadLetter = deadLetter; this.registry = registry; }
public RootController(ApplicationContext context, IHandlerRegistry handlerRegistry) { _context = context; _handlerRegistry = handlerRegistry; }
public MessageUnit Use(IHandlerRegistry registry) { this.registry = registry; return(this); }
public MessageHandlerDiscovery(IHandlerRegistry registry) { _registry = registry; }
public UnitIncomingPipelineFactory(IHandlerRegistry registry, ICollection <LogicalMessage> incoming) { this.incoming = incoming; this.registry = registry; }
public DynamicDispatcher(IHandlerRegistry handlerRegistry, IServiceProvider serviceProvider, IUnitOfWork unitOfWork) { this.handlerRegistry = handlerRegistry; this.serviceProvider = serviceProvider; this.unitOfWork = unitOfWork; }
public static IReadOnlyCollection <object> ConsumeAll(this IHandlerRegistry registry) { return(new ReadOnlyCollection <object>(new List <object>())); }
public static IEnumerable <IQueryHandlerWrapper <TQuery, TResult> > GetQueryHandlerWrappers <TQuery, TResult>(this IHandlerRegistry handlerRegistry) where TQuery : IQuery <TResult> => handlerRegistry.GetQueryHandlerWrappers(typeof(TQuery), typeof(TResult)).Cast <IQueryHandlerWrapper <TQuery, TResult> >();
public static IEnumerable <Func <object, Action <object>, Task> > FindHandler <T>(this IHandlerRegistry registry) { return(registry.FindHandler(typeof(T))); }
public IncomingPipelineFactory(IHandlerRegistry registry, IMessageSerializer serializer) { this.registry = registry; this.serializer = serializer; }
public LoadMessageHandlersStep(IHandlerRegistry registry) { this.registry = registry; }
private CommandInterpreter(IDictionary <int, CommandHandler> interpreters, IDictionary <Type, FormatterInfo> formatters) { this.interpreters = CreateRegistry(interpreters); this.formatters = ImmutableDictionary.ToImmutableDictionary(formatters); }
public DefaultEventDispatcher(IHandlerRegistry handlerRegistry) : this(handlerRegistry, new DefaultHandlerInvoker()) { }