internal void ShowTaskSummary(ITaskSummary summary) { string summaryText; if (summary == null) { summaryText = "No summary."; } else if (summary is StringTaskSummary) { summaryText = (StringTaskSummary)summary; } else if (summary is DictionaryTaskSummary) { summaryText = string.Join(Environment.NewLine, ((DictionaryTaskSummary)summary).Select(p => "{0} = {1}".FormatInvariant(p.Key, p.Value))); } else { summaryText = string.Concat(summary, Environment.NewLine, Environment.NewLine, string.Join(Environment.NewLine, summary.GetType().GetProperties() .Select(p => "{0} = {1}".FormatInvariant(p.Name, p.GetValue(summary))))); } MessageBox.Show(summaryText, "Task Summary", MessageBoxButton.OK, MessageBoxImage.Information); }
/// <inheritdoc /> public void Add(Guid taskId, ITaskSummary summary) { Trace.WriteLine("ENTER: Adding summary '{0}' for task '{1}' ...".FormatInvariant(summary, taskId)); if (summary == null) { throw new ArgumentNullException(nameof(summary)); } string taskIdAsString = RedisConverter.ToString(taskId); byte[] content = this.serializer.Serialize(summary); if (this.serializer.CanDetermineEntityTypeFromContent) { this.provider.SetHashValue(RedisTaskSummaryRepository.RedisTaskSummaryHashKey, taskIdAsString, content); } else { using (IRedisTransaction transaction = this.provider.CreateTransaction()) { transaction.SetHashValue(RedisTaskSummaryRepository.RedisTaskSummaryHashKey, taskIdAsString, content); transaction.SetHashValue(RedisTaskSummaryRepository.RedisTaskSummaryHashKey, taskIdAsString + "$Type", RedisConverter.ToString(summary.GetType(), false)); transaction.Commit(); } } Trace.WriteLine("EXIT: Summary '{0}' added for task '{1}'.".FormatInvariant(summary, taskId)); }