public static OscMessage StringToOscMessage(string message)
{
OscMessage oM = new OscMessage();
// Console.WriteLine("Splitting " + message);
string[] ss = message.Split(new char[] { ' ' });
IEnumerator sE = ss.GetEnumerator();
if (sE.MoveNext())
oM.Address = (string)sE.Current;
while ( sE.MoveNext() )
{
string s = (string)sE.Current;
// Console.WriteLine(" <" + s + ">");
if (s.StartsWith("\""))
{
StringBuilder quoted = new StringBuilder();
bool looped = false;
if (s.Length > 1)
quoted.Append(s.Substring(1));
else
looped = true;
while (sE.MoveNext())
{
string a = (string)sE.Current;
// Console.WriteLine(" q:<" + a + ">");
if (looped)
quoted.Append(" ");
if (a.EndsWith("\""))
{
quoted.Append(a.Substring(0, a.Length - 1));
break;
}
else
{
if (a.Length == 0)
quoted.Append(" ");
else
quoted.Append(a);
}
looped = true;
}
oM.Values.Add(quoted.ToString());
}
else
{
if (s.Length > 0)
{
try
{
int i = int.Parse(s);
// Console.WriteLine(" i:" + i);
oM.Values.Add(i);
}
catch
{
try
{
float f = float.Parse(s);
// Console.WriteLine(" f:" + f);
oM.Values.Add(f);
}
catch
{
// Console.WriteLine(" s:" + s);
oM.Values.Add(s);
}
}
}
}
}
return oM;
}