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);
            });
        }
예제 #2
0
 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)));
 }
예제 #3
0
 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))));
 }
예제 #4
0
 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;
         }
     });
 }
예제 #5
0
파일: Shell.cs 프로젝트: kzu/guit
        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();
                }
            }));
        }
예제 #6
0
        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);
            //		}
            //	});
        }
예제 #8
0
파일: StatusBar.cs 프로젝트: kzu/guit
        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);
        }
예제 #9
0
 public SendMailHandler(IEventStream eventStream)
 {
     this.subscription = eventStream.Of <IEvent <Product, ProductPublishedEvent> >().Subscribe(this.OnProductPublished);
 }
예제 #10
0
 public void Connect(IEventStream stream)
 {
     subscription = stream.Of<IDevice, IssuedCommand>().Subscribe(e => store.Save(e.Sender, e.EventArgs));
 }
예제 #11
0
	public SendMailHandler(IEventStream eventStream)
	{
		this.subscription = eventStream.Of<IEvent<Product, ProductPublishedEvent>>().Subscribe(this.OnProductPublished);
	}
예제 #12
0
파일: Program.cs 프로젝트: netfx/extensions
			public ConsoleHandler(IEventStream eventStream)
			{
				this.subscription = eventStream.Of<IEvent<EventArgs>>().Subscribe(this.OnEvent);
			}
예제 #13
0
 public SelectionService(IEventStream eventStream)
 {
     this.eventStream = eventStream;
     eventStream.Of <SelectionChanged>().Subscribe(OnSelectionChanged);
 }
예제 #14
0
 public ConsoleHandler(IEventStream eventStream)
 {
     this.subscription = eventStream.Of <IEvent <EventArgs> >().Subscribe(this.OnEvent);
 }