protected void OnLogIntercepted(LogMessage message) { var temp = LogIntercepted; if (temp != null) { LogInterceptedEventArgs args = new LogInterceptedEventArgs(message); temp(this, args); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void LogIntercepted(object sender, LogInterceptedEventArgs e) { App.ExecuteInUiThread(() => { _Logs.Add(new LogMessageViewModel(e.Message)); if (!String.IsNullOrEmpty(e.Message.OpType)) { if ("command".Equals(e.Message.OpType, StringComparison.OrdinalIgnoreCase)) { //I already have a logger for this command? var alvm = Commands.SingleOrDefault(c => c.Identifier == e.Message.OpTypeId); if (alvm == null) { alvm = new AggregateLogMessageViewModel() { Identifier = e.Message.OpTypeId }; Commands.Add(alvm); } alvm.Logs.Add(new LogMessageViewModel( e.Message)); } else if ("event".Equals(e.Message.OpType, StringComparison.OrdinalIgnoreCase)) { //I already have a logger for this command? var alvm = Handlers.SingleOrDefault(c => c.Identifier == e.Message.OpTypeId); if (alvm == null) { alvm = new AggregateLogMessageViewModel() { Identifier = e.Message.OpTypeId }; Handlers.Add(alvm); } alvm.Logs.Add(new LogMessageViewModel(e.Message)); } else { //Generic optype var alogs = AggregatedLogs.SingleOrDefault(al => al.OperationType.Equals(e.Message.OpType)); if (alogs == null) { alogs = new OpTypeLoggerViewModel(e.Message.OpType); AggregatedLogs.Add(alogs); } //now I have the container for the aggregate var aggl = alogs.AggregatedLogs.SingleOrDefault(c => c.Identifier == e.Message.OpTypeId); if (aggl == null) { aggl = new AggregateLogMessageViewModel() { Identifier = e.Message.OpTypeId }; alogs.AggregatedLogs.Add(aggl); } aggl.Logs.Add(new LogMessageViewModel(e.Message)); } } }); }