/// <summary> /// Creates an observable for smart card events. /// </summary> /// <param name="factory">Factory to use for <see cref="ISCardMonitor"/> creation.</param> /// <param name="scope">Scope of the establishment. This can either be a local or remote connection.</param> /// <param name="readerNames">Name of the smart card reader that shall be monitored.</param> /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param> /// <returns></returns> public static IObservable <MonitorEvent> CreateObservable(this IMonitorFactory factory, SCardScope scope, IEnumerable <string> readerNames, IScheduler scheduler = null) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } if (readerNames == null) { throw new ArgumentNullException(nameof(readerNames)); } return(Observable.Create <MonitorEvent>(obs => { var monitor = factory.Create(scope); var useScheduler = scheduler ?? Scheduler.ForCurrentContext(); var readers = readerNames .Where(name => !string.IsNullOrWhiteSpace(name)) .ToArray(); var subscription = monitor .ObserveEvents(useScheduler) .Subscribe(obs); monitor.Start(readers); return new CompositeDisposable(subscription, monitor); })); }
public void Monitor(IEnumerable <ProductBase> productsBase) { foreach (var productBase in productsBase) { _monitorFactory.Create(productBase).Invoke(); } }
public ServiceEndpointClientMonitoringProxy(IServiceEndpointClient <TMessage, TCommand, TEvent, TRequest, TResponse> endpointClient, IMonitorFactory <TMessage> monitorFactory) { if (endpointClient == null) { throw new NullReferenceException("endpointClient cannot be null"); } if (monitorFactory == null) { throw new NullReferenceException("monitorFactory cannot be null"); } _endpointClient = endpointClient; _monitor = monitorFactory.Create(endpointClient.Name); }