public static Message FromOSC(Stream stream) { var ms = new MemoryStream(); stream.CopyTo(ms); var bytes = ms.ToArray(); var start = 0; var bundle = OSCBundle.Unpack(bytes, ref start, (int)stream.Length); var message = new Message(); foreach (OSCMessage m in bundle.Values) { var binList = new BinList(); binList.AssignFrom(m.Values); // does not clone implicitly var address = m.Address.Split('/'); var name = address[address.Length - 1]; address[address.Length - 1] = ""; var messageAddress = ""; foreach (var part in address) { if (part.Trim() != "") messageAddress += "." + part; } message.Address = messageAddress.Substring(1); message[name] = binList; } return message; }
public static Message FromOSC(Stream stream) { MemoryStream ms = new MemoryStream(); stream.CopyTo(ms); byte[] bytes = ms.ToArray(); int start = 0; OSCBundle bundle = OSCBundle.Unpack(bytes, ref start, (int)stream.Length); Message message = new Message(); // yet unsupported: // message.TimeStamp = DateTime.FromFileTime(bundle.getTimeStamp()); foreach (OSCMessage m in bundle.Values) { BinList bl = new BinList(); bl.AssignFrom(m.Values); // does not clone implicitly string[] address = m.Address.Split('/'); string name = address[address.Length-1]; address[address.Length-1] = ""; string messageAddress = ""; foreach (string part in address) { if (part.Trim() != "") messageAddress += "."+part; } message.Address = messageAddress.Substring(1); message[name] = bl; } return message; }
public object Clone() { var message = new Message {Address = Address, TimeStamp = TimeStamp}; foreach (var name in FDictionary.Keys) { var list = FDictionary[name]; message.Add(name, list.Clone()); // really deep cloning try { for(var i = 0; i < list.Count; i++) { list[i] = ((ICloneable)list[i]).Clone(); } } catch (Exception err) { err.ToString(); // no warning // not cloneble. so keep it } } return message; }
public object Clone() { Message m = new Message(); m.Address = Address; m.TimeStamp = TimeStamp; foreach (string name in dictionary.Keys) { BinList list = dictionary[name]; m.Add(name, list.Clone()); // really deep cloning try { for(int i =0;i<list.Count;i++) { list[i] = ((ICloneable)list[i]).Clone(); } } catch (Exception err) { err.ToString(); // no warning // not cloneble. so keep it } } return m; }