protected override PokeResult OnPoke(DdeConversation conversation, string item, byte[] data, int format) { int rowLength = topicRowLengthMap[conversation.Topic]; string[] dataArr = new string[rowLength]; int dataCounter = -2; //because of 2 metadata symbols like: some number and type D: LOGGER.Debug("recieved information from quik: topic={0}, data={1}", conversation.Topic, String.Join(" ", dataArr)); { foreach (Object o in XlTableFormat.Read(data)) { dataCounter++; if (dataCounter < 0) { continue; } dataArr[dataCounter % rowLength] = o.ToString(); if ((dataCounter + 1) % rowLength == 0 && dataCounter != 0) { if (OnDataUpdate != null) { OnDataUpdate(conversation.Topic, dataArr); } dataArr = new string[rowLength]; } } } LOGGER.Debug("Successfully recieved and sended to data collector."); return(PokeResult.Processed); }
[Test] // ReSharper disable once InconsistentNaming public void Read_ThrowsWithNullFactory() { var e = Assert.Throws <ArgumentNullException>(() => XlTableFormat.Read(new byte[0], (IXlTableDataFactory <object>)null)); Assert.That(e.ParamName, Is.EqualTo("factory")); }
[Test] // ReSharper disable once InconsistentNaming public void Read_ThrownWithNullData() { var e = Assert.Throws <ArgumentNullException>(() => XlTableFormat.Read((byte[])null)); Assert.That(e.ParamName, Is.EqualTo("data")); }
[Test] // ReSharper disable once InconsistentNaming public void Read_ThrowsWithNullFactoryUsingStreamOverload() { var e = Assert.Throws <ArgumentNullException>(() => // ReSharper disable once IteratorMethodResultIsIgnored XlTableFormat.Read(Stream.Null, (IXlTableDataFactory <object>)null)); Assert.That(e.ParamName, Is.EqualTo("factory")); }
static Reader <object> Read(params byte[] bytes) { return(Reader.Create(XlTableFormat.Read(new MemoryStream(bytes, writable: false)))); }
public DdeMessage(byte[] data, string topic = "", string item = "") { this.Table = XlTableFormat.Read(data, (rows, cols, cells) => new DdeTable(rows, cols, cells)); this.Topic = topic; this.Item = item; }