/// <summary> /// Parses a text stream. /// </summary> /// <param name="stream">a text stream for parsing</param> public void Parse(TextStream stream) { stream.ValidateVerbatimText('['); var componentId = stream.ReadInt32(); stream.ValidateVerbatimText(']'); var componentName = stream.ReadAStringForCharacter('['); if (string.IsNullOrEmpty(componentName)) { var message = string.Format("Invalid component name = {0}", componentName); throw new ArgumentException(message); } var component = this.components.Find(componentId, componentName); if (component != null) component.Parse(stream); }
static Quote Parse(string text) { var stream = new TextStream(); stream.Initialize(text); var lrpQuote = stream.ReadQuote("quote"); var bids = new QuoteEntry[lrpQuote.Bids.Length]; var asks = new QuoteEntry[lrpQuote.Asks.Length]; for (int index = 0; index < lrpQuote.Bids.Length; ++index) { bids[index] = new QuoteEntry(lrpQuote.Bids[index].Price, lrpQuote.Bids[index].Volume); } for (int index = 0; index < lrpQuote.Asks.Length; ++index) { asks[index] = new QuoteEntry(lrpQuote.Asks[index].Price, lrpQuote.Asks[index].Volume); } var result = new Quote(lrpQuote.Symbol, lrpQuote.CreatingTime, bids, asks); return result; }