예제 #1
0
        /// <summary>
        /// Creates a <see cref="Stock"/> entity for insertion from a <see cref="StockData"/> object
        /// </summary>
        /// <param name="stockData"></param>
        /// <returns></returns>
        private static Stock CreateStock(StockData stockData)
        {
            var stock = stockData.ToStockEntity();

            stock.Created = DateTime.Now;
            stock.Modified = DateTime.Now;

            return stock;
        }
예제 #2
0
        /// <summary>
        /// Translates a quote element into a <see cref="StockQuote"/>
        /// </summary>
        /// <param name="quoteElement"></param>
        /// <returns></returns>
        private StockData TranslateToStockData(XmlElement quoteElement)
        {
            // get the symbol
            var symbol = quoteElement.GetAttribute(SymbolAttributeName);
            if (string.IsNullOrWhiteSpace(symbol)) throw new YqlResponseNodeMissingException(SymbolAttributeName);
            
            // create quote
            var stockData = new StockData { Symbol = symbol };

            // get a property mapper
            var propertyMapper = _yqlPropertyMapperFactory.GetPropertyMapper();

            // set properties on the quote 
            propertyMapper.SetPropertiesFromXml(stockData, quoteElement.ChildNodes.OfType<XmlElement>());

            return stockData;
        }