public virtual async Task <ComposedValue> GetComposedValue( string parameter, Session session, CancellationToken cancellationToken) { var chatTail = await ChatService.GetChatTail(1, cancellationToken); var uptime = await TimeService.GetUptime(10, cancellationToken); var sum = (double?)null; if (double.TryParse(parameter, out var value)) { sum = await SumService.GetSum(new [] { value }, true, cancellationToken); } var lastChatMessage = chatTail.Messages.SingleOrDefault()?.Text ?? "(no messages)"; var user = await AuthService.GetUser(session, cancellationToken); var activeUserCount = await ChatService.GetActiveUserCount(cancellationToken); return(new ComposedValue() { Parameter = $"{parameter} - server", Uptime = uptime, Sum = sum, LastChatMessage = lastChatMessage, User = user, ActiveUserCount = activeUserCount }); }
public virtual async Task <ComposedValue> GetComposedValueAsync( string parameter, Session session, CancellationToken cancellationToken) { var chatTail = await ChatService.GetChatTailAsync(1, cancellationToken).ConfigureAwait(false); var uptime = await TimeService.GetUptimeAsync(TimeSpan.FromSeconds(10), cancellationToken).ConfigureAwait(false); var sum = (double?)null; if (double.TryParse(parameter, out var value)) { sum = await SumService.SumAsync(new [] { value }, true, cancellationToken).ConfigureAwait(false); } var lastChatMessage = chatTail.Messages.SingleOrDefault()?.Text ?? "(no messages)"; var user = await AuthService.GetUserAsync(session, cancellationToken).ConfigureAwait(false); var activeUserCount = await ChatService.GetActiveUserCountAsync(cancellationToken).ConfigureAwait(false); return(new ComposedValue($"{parameter} - server", uptime, sum, lastChatMessage, user, activeUserCount)); }