private Message Broadcast(BroadcastMessageDelegate broadcastDelegate, string channel, Exception ex, string source = null) { Message data = new Message(); data.Text = ex != null ? ex.Message : null; data.SourceName = source; data.Guid = Guid.NewGuid(); return(Broadcast(broadcastDelegate, channel, data)); }
private Message Broadcast(BroadcastMessageDelegate broadcastDelegate, string channel, string message, string source = null, params object[] args) { Message data = new Message(); data.SourceName = source; data.Guid = Guid.NewGuid(); if (args == null || args.Length == 0) { data.Text = message; } else { // it's a formated message data.Text = String.Format(message, args); } return(Broadcast(broadcastDelegate, channel, data)); }
private Message Broadcast(BroadcastMessageDelegate broadcastDelegate, string channel, Message msg) { msg.Channel = channel; msg.BroadcastedAt = DateTime.Now; if (broadcastDelegate != null) { broadcastDelegate(msg); } else { // no broadcast-delegate given means that the message came over the neutral Broadcast()-method // if it is a default channel (e.g. "info") call the specific delegates manually if (OnDebugMessage != null && msg.Channel.ToLower() == "debug") { OnDebugMessage(msg); } if (OnInfoMessage != null && msg.Channel.ToLower() == "info") { OnInfoMessage(msg); } if (OnWarningMessage != null && msg.Channel.ToLower() == "warning") { OnWarningMessage(msg); } if (OnErrorMessage != null && msg.Channel.ToLower() == "error") { OnErrorMessage(msg); } } // broadcast all messages if (OnAnyMessage != null) { OnAnyMessage(msg); } return(msg); }