示例#1
0
        public IDisposable Configure(PulseVM pulseVM, out OnPushUpdate onPushUpdate)
        {
            // Property names.
            string Logs;
            string SelectedLog;

            var selectedLog = pulseVM.AddProperty <DateTimeOffset>(nameof(SelectedLog));

            pulseVM.AddProperty(nameof(Logs), new LogItem[] { new LogItem(LogLevel.None, "Pulse logger started") })
            .WithItemKey(nameof(LogItem.Time))
            .WithAttribute(
                new DataGridAttribute
            {
                RowKey  = nameof(LogItem.Time),
                Columns = new DataGridColumn[]
                {
                    new DataGridColumn(nameof(LogItem.FormattedTime), "Time")
                    {
                        Sortable = true
                    },
                    new DataGridColumn(nameof(LogItem.Level), "Level")
                    {
                        Sortable = true
                    },
                    new DataGridColumn(nameof(LogItem.Message), "Message")
                },
                Rows = _logConfig.Rows
            }
                .CanSelect(DataGridAttribute.Selection.Single, selectedLog)
                );

            var cachedLogs = new List <LogItem>();

            onPushUpdate = liveUpdate =>
            {
                lock (cachedLogs)
                {
                    if (liveUpdate && cachedLogs.Count > 0)
                    {
                        pulseVM.AddList(nameof(Logs), cachedLogs.ToArray());
                        selectedLog.Value = cachedLogs.Last().Time;
                    }
                    cachedLogs.Clear();
                }
            };

            return(_logStream.Subscribe(log =>
            {
                lock (cachedLogs)
                {
                    cachedLogs.Add(log);
                }
            }));
        }
        public IDisposable Configure(PulseVM pulseVM, out OnPushUpdate onPushUpdate)
        {
            // Property names.
            string GCTotalMemory;
            string GCTotalMemoryTrend;

            int tick = 0;

            pulseVM.AddProperty <double>(nameof(GCTotalMemory))
            .WithAttribute(new { Label = "GC Total Memory", Unit = "MB" })
            .SubscribeTo(_dataStream.Select(x => x.GCTotalMemory))
            .SubscribedBy(value => pulseVM.AddList(nameof(GCTotalMemoryTrend), ToChartData(++tick, value)), out IDisposable totalMemoryTrendSubs);

            pulseVM.AddProperty(nameof(GCTotalMemoryTrend), new string[][] { ToChartData(tick, _process.GCTotalMemory) })
            .WithAttribute(new ChartAttribute
            {
                Title       = "GC Total Memory",
                XAxisLabel  = "Time",
                YAxisLabel  = "MBytes",
                MaxDataSize = 60,
                YAxisMin    = 0,
                YAxisMax    = 100
            });

            onPushUpdate = _ =>
            {
            };

            var intervalSubs = Observable
                               .Interval(TimeSpan.FromMilliseconds(_interval))
                               .Subscribe(_ => _dataStream.OnNext(_process));

            return(new Disposable(totalMemoryTrendSubs, intervalSubs));
        }