public static ISoftBetIntegration.Game Get(ceDomainConfigEx domain, string gameID, bool funMode, bool isHtmlGame, string lang, params string[] countryCodes) { if (!SupportedLanguages.Contains(lang.ToLowerInvariant())) { lang = DEFAULT_LANGUAGE; } ISoftBetIntegration.Game game = null; string url = domain.GetCountrySpecificCfg(CE.DomainConfig.ISoftBet.TargetServer, countryCodes); if (isHtmlGame) { url = string.Format(domain.GetCountrySpecificCfg(CE.DomainConfig.ISoftBet.HTML5GameFeedsURL, countryCodes) , url , lang); } else { url = string.Format(domain.GetCountrySpecificCfg(CE.DomainConfig.ISoftBet.FlashGameFeedsURL, countryCodes) , url , lang); } string xml = GetRawXmlFeeds(url); XDocument xDoc = XDocument.Parse(xml); IEnumerable <XElement> elements = xDoc.Root.Element("games").Elements("c"); foreach (XElement element in elements) { string cid = element.GetAttributeValue("id"); var cels = from x in element.Elements("g") where string.Equals(x.Attribute("i").Value, gameID) select x; if (cels != null && cels.Count() > 0) { string targetServer = funMode ? domain.GetCountrySpecificCfg(CE.DomainConfig.ISoftBet.TargetServer, countryCodes) : domain.GetCountrySpecificCfg(CE.DomainConfig.ISoftBet.RealModeTargetServer, countryCodes); game = isHtmlGame ? AnalyzeElementForHtmlGame(cels.First(), domain, cid, funMode, targetServer) : AnalyzeElementForFlashGame(cels.First(), domain, cid, funMode, targetServer); game = InitGameInfo(domain, game, funMode, countryCodes); break; } } return(game); }
private static Game AnalyzeElementForFlashGame(XElement element, ceDomainConfigEx domain, string cid, bool funMode, string targetServer, params string[] countryCodes) { ISoftBetIntegration.Game g = new ISoftBetIntegration.Game(); g.CategoryID = cid; g.PresentationType = PresentationType.Flash; //g.ID = gEle.GetAttributeValue("id"); g.ID = element.GetAttributeValue("i"); if (g.ID.ToLowerInvariant() == "heavy_metal_pmvc") { g.ID = g.ID; } g.Identifier = element.GetAttributeValue("i"); g.Name = element.GetAttributeValue("n"); g.Image = element.GetAttributeValue("img"); g.FunModel = string.Equals(element.GetAttributeValue("fa"), "1", StringComparison.InvariantCultureIgnoreCase); g.RealModel = string.Equals(element.GetAttributeValue("ra"), "1", StringComparison.InvariantCultureIgnoreCase); g.TestFunMode = string.Equals(element.GetAttributeValue("tfa"), "1", StringComparison.InvariantCultureIgnoreCase); g.TestRealMode = string.Equals(element.GetAttributeValue("tra"), "1", StringComparison.InvariantCultureIgnoreCase); g.UserIDs = element.GetAttributeValue("ta").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); string strCoins = element.GetAttributeValue("c"); if (!string.IsNullOrWhiteSpace(strCoins)) { string[] coins = strCoins.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (coins != null && coins.Length > 0) { g.Coins = new decimal[coins.Length]; for (int i = 0; i < coins.Length; i++) { decimal.TryParse(coins[i], out g.Coins[i]); } } } g.Translated = element.GetAttributeValue("translated") == "1"; g.Description = element.GetElementValue("d"); return(g); }