Libmpc.MpcConnection.Exec C# (CSharp) Method

Exec() public method

Executes a MPD command with arguments on the MPD server.
If the command contains a space of a newline charakter.
public Exec ( string command, string argument ) : MpdResponse
command string The command to execute.
argument string The arguments of the command.
return MpdResponse
        public MpdResponse Exec(string command, string[] argument)
        {
            if (command == null)
            throw new ArgumentNullException("command");
              if (command.Contains(" "))
            throw new ArgumentException("command contains space");
              if (command.Contains("\n"))
            throw new ArgumentException("command contains newline");

              if (argument == null)
            throw new ArgumentNullException("argument");
              for (int i = 0; i < argument.Length; i++) {
            if (argument[i] == null)
              throw new ArgumentNullException("argument[" + i + "]");
            if (argument[i].Contains("\n"))
              throw new ArgumentException("argument[" + i + "] contains newline");
              }

              //if (m_Commands != null && !m_Commands.Contains(command))
              //  return new MpdResponse(new ReadOnlyCollection<string>(new List<string>()));

              try {
            this.CheckConnected();
            m_Mutex.WaitOne();
            m_SocketManager.WriteLine(string.Format("{0} {1}", command, string.Join(" ", argument)));

            MpdResponse res = this.readResponse();
            m_Mutex.ReleaseMutex();
            return res;
              }
              catch (Exception) {
            try { this.Disconnect(); }
            catch (Exception) { }
            return new MpdResponse(new ReadOnlyCollection<string>(new List<string>()));
            //throw;
              }
        }

Same methods

MpcConnection::Exec ( string command ) : MpdResponse