public static IDisposable RegisterService <TEvent>( this IEventStream eventStream, string name, Action onStart, Action onStop, Action onPrepare = null, Action <TEvent> onNext = null) { return(eventStream.RegisterService <TEvent>( onStart: onStart, onStop: onStop, onPrepare: onPrepare, onNext: onNext)); }
public static IDisposable RegisterService <TEvent>( this IEventStream eventStream, IService service) { var name = string.IsNullOrWhiteSpace(service.Name) ? service.Name : service.GetType().ToString(); var cts = new CancellationTokenSource(); return(eventStream.RegisterService <TEvent>( name, onStart: () => service.Start(cts.Token), onStop: () => { cts.Cancel(); service.Stop(); })); }