public new static OscBundle Parse(ref OscStringReader reader, IFormatProvider provider = null, OscSerializationToken endToken = OscSerializationToken.End) { if (provider == null) { provider = CultureInfo.InvariantCulture; } string ident = reader.ReadAddress(false) .Trim(); if (BundleIdent.Equals(ident, StringComparison.Ordinal) == false) { throw new Exception($"Invalid bundle ident '{ident}'"); } reader.ReadSeparator(); if (reader.ReadNextToken(out string timeStampStr) != OscSerializationToken.Literal) { throw new Exception("Invalid bundle timestamp"); } OscTimeTag timeStamp = OscTimeTag.Parse(timeStampStr.Trim(), provider); if (reader.ReadSeparatorOrEnd() == endToken) { return(new OscBundle(timeStamp)); } List <OscPacket> packets = new List <OscPacket>(); OscSerializationToken token = OscSerializationToken.None; token = reader.ReadNextToken(out string _); while (token != endToken && token != OscSerializationToken.End) { if (token != OscSerializationToken.ObjectStart) { throw new Exception("Invalid bundle token"); } packets.Add(OscPacket.Parse(ref reader, provider, OscSerializationToken.ObjectEnd)); token = reader.ReadNextToken(out string _); if (token == OscSerializationToken.Separator) { token = reader.ReadNextToken(out string _); } } if (token != endToken) { throw new OscException(OscError.UnexpectedToken, $"Unexpected token {token}"); } return(new OscBundle(timeStamp, packets.ToArray())); }
public new static OscMessage Parse(ref OscStringReader reader, IFormatProvider provider = null, OscSerializationToken endToken = OscSerializationToken.End) { string address = reader.ReadAddress(true); // parse arguments List <object> arguments = new List <object>(reader.ReadArguments(provider, endToken)); return(new OscMessage(address, arguments.ToArray())); }