protected static void AddToCommand(Command command, string key, object value)
        {
            if (command == null)
                throw new ArgumentNullException("command");

            if (value == null)
                return;

            if (key.IsNullOrTrimmedEmpty())
                throw new ArgumentException("key is null or trimmed empty.");

            if (value is bool? || value is bool)
                command.AddParameter(key, ((bool) value) ? "1" : "0");
            else if (value is TimeSpan? || value is TimeSpan)
                command.AddParameter(key, ((TimeSpan)value).TotalSeconds.ChangeTypeInvariant<string>());
            else
                command.AddParameter(key, Convert.ToString(value, CultureInfo.InvariantCulture));
        }
Пример #2
0
 /// <summary>
 /// Sends a message to the current channel's chat
 /// </summary>
 /// <param name="msg">The message to send</param>
 public void SendChannelMessage(string msg)
 {
     logger.Info("Sending text message: {0}", msg);
     var command = new Command("sendtextmessage targetmode=2");
     command.AddParameter("msg", msg);
     logger.Info("Command: {0}", command.ToString());
     this.TsConnection.SendCommand(command);
 }
Пример #3
0
 /// <summary>
 /// Sends a message to the current channel's chat
 /// </summary>
 /// <param name="msg">The message to send</param>
 public void SendChannelMessage(string msg)
 {
     if (this.CommandQueryRunner != null)
     {
         logger.Info("Sending text message: {0}", msg);
         var command = new Command("sendtextmessage targetmode=2");
         command.AddParameter("msg", msg);
         logger.Info("Command: {0}", command.ToString());
         this.CommandQueryRunner.SendCommand(command);
     }
 }