void SubscribeTelemetryEvents() { events .Of <object>() .Where(ev => ev.IsBrowsable()) .Subscribe(x => { var ev = x as Event; if (ev == null) { var eventName = x.GetName(); var properties = x.GetProperties(); var metrics = x.GetMetrics(); telemetry.TrackEvent(eventName, properties, metrics); } else { telemetry.TrackEvent(ev.Name, ev.Properties, ev.Metrics); } }); events .Of <TelemetryError> () .Subscribe(err => { telemetry.TrackError(err); }); }
public void Connect(IEventStream stream) { subscription = new CompositeDisposable( stream.Of<IEventPattern<IDevice, IImpulse<bool>>>() .Subscribe(i => state.Set(i.EventArgs.Topic, i.Sender.Id, i.EventArgs.Payload)), stream.Of<IEventPattern<IDevice, IImpulse<float>>>() .Subscribe(i => state.Set(i.EventArgs.Topic, i.Sender.Id, i.EventArgs.Payload)), stream.Of<IEventPattern<IDevice, IImpulse<string>>>() .Subscribe(i => state.Set(i.EventArgs.Topic, i.Sender.Id, i.EventArgs.Payload))); }
public void Connect(IEventStream stream) { subscription = new CompositeDisposable( stream.Of<ICommand<bool>>().Subscribe(cmd => stream.Push(Command.Create(cmd.Topic, Payload.ToBytes(cmd.Payload), cmd.Timestamp, cmd.TargetDeviceIds))), stream.Of<ICommand<float>>().Subscribe(cmd => stream.Push(Command.Create(cmd.Topic, Payload.ToBytes(cmd.Payload), cmd.Timestamp, cmd.TargetDeviceIds))), stream.Of<ICommand<string>>().Subscribe(cmd => stream.Push(Command.Create(cmd.Topic, Payload.ToBytes(cmd.Payload), cmd.Timestamp, cmd.TargetDeviceIds))), stream.Of<ICommand<Unit>>().Subscribe(cmd => stream.Push(Command.Create(cmd.Topic, new byte[0], cmd.Timestamp, cmd.TargetDeviceIds)))); }
public void Connect(IEventStream stream) { subscription = stream.Of<IEventPattern<IDevice, ISensed>>().Subscribe(sensed => { var type = topicRegistry.Find(sensed.EventArgs.Topic); switch (type) { case TopicType.Boolean: stream.Push(sensed.Sender, Impulse.Create(sensed.EventArgs.Topic, Payload.ToBoolean(sensed.EventArgs.Payload), clock.Now)); break; case TopicType.Number: stream.Push(sensed.Sender, Impulse.Create(sensed.EventArgs.Topic, Payload.ToNumber(sensed.EventArgs.Payload), clock.Now)); break; case TopicType.String: stream.Push(sensed.Sender, Impulse.Create(sensed.EventArgs.Topic, Payload.ToString(sensed.EventArgs.Payload), clock.Now)); break; case TopicType.Void: stream.Push(sensed.Sender, Impulse.Create(sensed.EventArgs.Topic, Unit.Default, clock.Now)); break; case TopicType.Unknown: default: // TODO: throw? Report? break; } }); }
public Shell( [ImportMany] IEnumerable <Lazy <ContentView, MenuCommandMetadata> > views, MainThread mainThread, Lazy <CommandService> commandService, IEventStream eventStream, IRepository repository) { this.views = views .OrderBy(x => x.Metadata.Order) .ThenBy(x => x.Metadata.Key); defaultView = this.views.First(); this.mainThread = mainThread; this.commandService = commandService; this.repository = repository; eventStream.Of <BranchChanged>().Subscribe(x => mainThread.Invoke(() => { if (CurrentView != null && shellWindows.TryGetValue(CurrentView, out var shellWindow)) { shellWindow.Refresh(); } })); }
public ReportStatusProgress(string title, IEventStream eventStream, MainThread mainThread) { Title = title; this.mainThread = mainThread; statusSubscription = eventStream.Of <Status>().Subscribe(OnStatus); minimalProgressDialog = new MinimalProgressDialog(title); mainThread.Invoke(() => Application.Run(minimalProgressDialog)); }
public TestServerConnectionManager( IRemoteServerSourceManager serverSourceManager, IAsyncManager asyncManager, IEventStream eventStream) { this.serverSourceManager = serverSourceManager; //this.systemEvents = systemEvents; //this.solutionState = solutionState; this.asyncManager = asyncManager; this.eventStream = eventStream; connectionTypes = new ConcurrentDictionary <RemoteServerPlatform, bool>(); //systemEvents.PowerModeChanged += OnPowerChange; //systemEvents.SessionSwitch += OnSessionSwitch; //systemEvents.SessionEnded += OnSessionEnded; //this.solutionState.SolutionReady += async (sender, args) => { // await CheckServerSourcesAsync ().ConfigureAwait (continueOnCapturedContext: false); //}; //this.solutionState.SolutionClosed += async (sender, args) => { // await DisconnectAsync (unregisterServerSource: true).ConfigureAwait (continueOnCapturedContext: false); //}; eventStream .Of <ProjectChanged>() .Subscribe(async ev => { if (ev.HasProjects) { await CheckServerSourceAsync(ev.Platform) .ConfigureAwait(continueOnCapturedContext: false); } }); //eventStream // .Of<StartupProjectsChanged> () // .Subscribe (async ev => { // foreach (var project in ev.StartupProjects) { // await TryConnectAsync (project.GetPlatform ()) // .ConfigureAwait (continueOnCapturedContext: false); // } // }); }
public StatusBar(IEventStream eventStream, Repository repository) { this.repository = repository; CanFocus = false; Height = 1; ColorScheme = new ColorScheme { Normal = Terminal.Gui.Attribute.Make(Color.White, Color.Black) }; status = new Label("Ready") { // Initially, we can only use the Frame of the top view, since Width is null at this point. // See LayoutSubviews below Width = Application.Top.Frame.Width - ClockText.Length }; clock = new Label(ClockText) { Width = ClockText.Length, X = Pos.Right(status) }; // To see the width of the clock itself, uncomment the following line //clock.ColorScheme = Colors.Error; Add(status, clock); Application.MainLoop.AddTimeout(TimeSpan.FromSeconds(1), _ => { clock.Text = ClockText; return(true); }); // Pushing simple strings to the event stream will cause them to update the // status message. eventStream.Of <Status>().Subscribe(OnStatus); }
public SendMailHandler(IEventStream eventStream) { this.subscription = eventStream.Of <IEvent <Product, ProductPublishedEvent> >().Subscribe(this.OnProductPublished); }
public void Connect(IEventStream stream) { subscription = stream.Of<IDevice, IssuedCommand>().Subscribe(e => store.Save(e.Sender, e.EventArgs)); }
public SendMailHandler(IEventStream eventStream) { this.subscription = eventStream.Of<IEvent<Product, ProductPublishedEvent>>().Subscribe(this.OnProductPublished); }
public ConsoleHandler(IEventStream eventStream) { this.subscription = eventStream.Of<IEvent<EventArgs>>().Subscribe(this.OnEvent); }
public SelectionService(IEventStream eventStream) { this.eventStream = eventStream; eventStream.Of <SelectionChanged>().Subscribe(OnSelectionChanged); }
public ConsoleHandler(IEventStream eventStream) { this.subscription = eventStream.Of <IEvent <EventArgs> >().Subscribe(this.OnEvent); }