Exemplo n.º 1
0
 private static IAsyncEventProcessor <T> CreateEventProcessor <T>(IDataProvider <T> dataProvider, AsyncSequenceBarrier sequenceBarrier, IAsyncBatchEventHandler <T> eventHandler)
     where T : class
 {
     return(EventProcessorFactory.Create(dataProvider, sequenceBarrier, eventHandler));
 }
Exemplo n.º 2
0
    /// <summary>
    /// Create a new <see cref="IEventProcessor{T}"/> with dedicated generic arguments.
    /// </summary>
    /// <typeparam name="T">the type of event used.</typeparam>
    /// <param name="dataProvider">dataProvider to which events are published</param>
    /// <param name="sequenceBarrier">SequenceBarrier on which it is waiting.</param>
    /// <param name="eventHandler">eventHandler is the delegate to which events are dispatched.</param>
    /// <returns></returns>
    public static IAsyncEventProcessor <T> Create <T>(IDataProvider <T> dataProvider, AsyncSequenceBarrier sequenceBarrier, IAsyncBatchEventHandler <T> eventHandler)
        where T : class
    {
        var dataProviderProxy = StructProxy.CreateProxyInstance(dataProvider);
        var sequencerOptions  = sequenceBarrier.GetSequencerOptions();
        var eventHandlerProxy = StructProxy.CreateProxyInstance(eventHandler);

        var eventProcessorType = typeof(AsyncBatchEventProcessor <, , ,>).MakeGenericType(typeof(T), dataProviderProxy.GetType(), sequencerOptions.GetType(), eventHandlerProxy.GetType());

        return((IAsyncEventProcessor <T>)Activator.CreateInstance(eventProcessorType, dataProviderProxy, sequenceBarrier, eventHandlerProxy) !);
    }