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;
}
}