Example #1
0
        public static IDisposable AttachPublisher <TEvent>(object IRxnPublisher, Type evt, IReactor <TEvent> reactor)
        {
            var p = IRxnPublisher;

            reactor.OnInformation("Configuring publisher '{0}:{1}'", p.GetType().Name, evt.Name);
            try
            {
                p.Invoke("ConfigiurePublishFunc", new object[] { new Action <TEvent>(reactor.Output.OnNext) });
            }
            catch (Exception e)
            {
                reactor.OnError(e, "Cannot configure publisher because of: {0}", e.Message);
                return(Disposable.Empty);
            }

            return(new DisposableAction(() =>
            {
                var publisher = p;
                publisher.Invoke("ConfigiurePublishFunc", new object[] { new Action <TEvent>(eve => { }) });
            }));
        }