/// <summary> /// Loads the WorldMarket data from text source. /// </summary> /// <param name="xmlText">The UTF-8 text source.</param> public static WorldMarket LoadTextSource(string xmlText) { try { XmlReaderSettings readerSettings = new XmlReaderSettings(); #if !(NETFX_CORE || SILVERLIGHT) XmlSchema sch = XmlSchema.Read(new System.IO.StringReader(Properties.Resources.market_schema), null); readerSettings.Schemas.Add(sch); readerSettings.ValidationType = ValidationType.Schema; #endif XmlReader market = XmlReader.Create(new System.IO.StringReader(xmlText), readerSettings); XmlSerializer ser = new XmlSerializer(typeof(System.Resources.WorldMarket)); System.Resources.WorldMarket wm = (System.Resources.WorldMarket)ser.Deserialize(market); WorldMarket result = new WorldMarket(); foreach (var s in wm.Sectors) { result.mSectors.Add(new Sector(s)); } foreach (var s in wm.Industries) { result.mIndustries.Add(new Industry(s, result)); } foreach (var s in wm.Currencies) { result.mCurrencies.Add(new CurrencyInfo(s)); } foreach (var s in wm.Countries) { result.mCountries.Add(new CountryInfo(s, result)); } foreach (var s in wm.StockExchanges) { result.mStockExchanges.Add(new StockExchange(s, result)); } foreach (var s in wm.Indices) { result.mIndices.Add(new YID(s, result)); } foreach (var s in wm.FundCategories) { result.mFundCategories.Add(new FundCategory(s)); } foreach (var s in wm.FundFamilies) { result.mFundFamilies.Add(new FundFamily(s)); } return result; } catch (Exception ex) { throw new Exception("The XML text is not valid. See InnerException for more details.", ex); } }
internal StockExchange(System.Resources.WorldMarketStockExchange orig, WorldMarket wm) : this() { this.ID = orig.ID; this.Name = orig.Name; this.Country = wm.GetCountryFromID(orig.Country); if (this.Country == null) throw new ArgumentException("orig.Country", "The passed country ID could not be found."); this.Suffix = orig.Suffix; this.TradingTime = new TradingTimeInfo(orig.TradingTime); }
internal CountryInfo(System.Resources.WorldMarketCountry orig, WorldMarket wm) : this(orig.ID, orig.Name, wm.GetCurrencyInfoFromID(orig.Currency)) { }
internal Industry(System.Resources.WorldMarketIndustry orig, WorldMarket wm) : this(orig.ID, orig.Name) { }
internal YID(System.Resources.WorldMarketIndex orig, WorldMarket wm) : this(orig.ID) { this.Name = orig.Name; this.Type = FinanceType.Index; this.StockExchange = wm.GetStockExchangeFromID(orig.StockExchange); if (this.StockExchange == null) throw new ArgumentException("The stock exchange ID could not be found.", "StockExchangeID"); this.StockExchange.Indices.Add(this); }