private void ParseSdkSetting(XmlNode sdkChannel) { _sdkChannelDict.Clear(); foreach (var node in sdkChannel.ChildNodes) { XmlElement childNode = node as XmlElement; if (childNode == null) { continue; } ChannelType channelType; try { channelType = MathUtils.ToEnum <ChannelType>(childNode.Name); } catch (Exception) { TraceLog.WriteError("The SDK config node \"{0}\" is not suport", childNode.Name); continue; } GameChannel gameChannel = new GameChannel(channelType); string url = childNode.GetAttribute("url"); if (!string.IsNullOrEmpty(url)) { gameChannel.Url = url; } string service = childNode.GetAttribute("service"); if (!string.IsNullOrEmpty(service)) { gameChannel.Service = service; } string version = childNode.GetAttribute("version"); if (!string.IsNullOrEmpty(version)) { gameChannel.Version = version; } string tokenUrl = childNode.GetAttribute("token_url"); if (!string.IsNullOrEmpty(tokenUrl)) { gameChannel.TokenUrl = tokenUrl; } string ctype = childNode.GetAttribute("type"); if (!string.IsNullOrEmpty(ctype)) { gameChannel.CType = ctype; } string channelId = childNode.GetAttribute("channelId"); if (!string.IsNullOrEmpty(channelId)) { gameChannel.ChannelId = channelId; } foreach (XmlElement item in childNode.ChildNodes) { var setting = new GameSdkSetting(); setting.RetailId = item.GetAttribute("name"); if (channelType == ChannelType.channelUC) { setting.AppId = item.GetAttribute("cpId"); setting.AppKey = item.GetAttribute("apiKey"); } else { setting.AppId = item.GetAttribute("appId"); setting.AppKey = item.GetAttribute("appKey"); } setting.AppSecret = item.GetAttribute("appSecret"); setting.GameId = item.GetAttribute("gameId"); setting.ServerId = item.GetAttribute("serverId"); gameChannel.Add(setting); } if (!_sdkChannelDict.ContainsKey(gameChannel.ChannelType)) { _sdkChannelDict.Add(gameChannel.ChannelType, gameChannel); } } }
private void ParseSdkSetting(XmlNode sdkChannel) { _sdkChannelDict.Clear(); foreach (XmlElement childNode in sdkChannel.ChildNodes) { ChannelType channelType; try { channelType = MathUtils.ToEnum<ChannelType>(childNode.Name); } catch(Exception ex) { TraceLog.WriteError(string.Format("SDK Game.Config.xml error: childNode.Name = {0} ; - ->{1}", childNode.Name, ex)); continue; } GameChannel gameChannel = new GameChannel(channelType); string url = childNode.GetAttribute("url"); if (!string.IsNullOrEmpty(url)) { gameChannel.Url = url; } string service = childNode.GetAttribute("service"); if (!string.IsNullOrEmpty(service)) { gameChannel.Service = service; } string version = childNode.GetAttribute("version"); if (!string.IsNullOrEmpty(version)) { gameChannel.Version = version; } string tokenUrl = childNode.GetAttribute("token_url"); if (!string.IsNullOrEmpty(tokenUrl)) { gameChannel.TokenUrl = tokenUrl; } string ctype = childNode.GetAttribute("type"); if (!string.IsNullOrEmpty(ctype)) { gameChannel.CType = ctype; } string channelId = childNode.GetAttribute("channelId"); if (!string.IsNullOrEmpty(channelId)) { gameChannel.ChannelId = channelId; } foreach (XmlElement item in childNode.ChildNodes) { var setting = new GameSdkSetting(); setting.RetailId = item.GetAttribute("name"); if (channelType == ChannelType.channelUC) { setting.AppId = item.GetAttribute("cpId"); setting.AppKey = item.GetAttribute("apiKey"); } else { setting.AppId = item.GetAttribute("appId"); setting.AppKey = item.GetAttribute("appKey"); } setting.AppSecret = item.GetAttribute("appSecret"); setting.GameId = item.GetAttribute("gameId"); setting.ServerId = item.GetAttribute("serverId"); gameChannel.Add(setting); } if (!_sdkChannelDict.ContainsKey(gameChannel.ChannelType)) { _sdkChannelDict.Add(gameChannel.ChannelType, gameChannel); } } }
private void ParseSdkSetting(XmlNode sdkChannel) { _sdkChannelDict.Clear(); foreach (XmlElement childNode in sdkChannel.ChildNodes) { ChannelType channelType = MathUtils.ToEnum <ChannelType>(childNode.Name); GameChannel gameChannel = new GameChannel(channelType); string url = childNode.GetAttribute("url"); if (!string.IsNullOrEmpty(url)) { gameChannel.Url = url; } string service = childNode.GetAttribute("service"); if (!string.IsNullOrEmpty(service)) { gameChannel.Service = service; } string version = childNode.GetAttribute("version"); if (!string.IsNullOrEmpty(version)) { gameChannel.Version = version; } string tokenUrl = childNode.GetAttribute("token_url"); if (!string.IsNullOrEmpty(tokenUrl)) { gameChannel.TokenUrl = tokenUrl; } string ctype = childNode.GetAttribute("type"); if (!string.IsNullOrEmpty(ctype)) { gameChannel.CType = ctype; } string channelId = childNode.GetAttribute("channelId"); if (!string.IsNullOrEmpty(channelId)) { gameChannel.ChannelId = channelId; } foreach (XmlElement item in childNode.ChildNodes) { var setting = new GameSdkSetting(); setting.RetailId = item.GetAttribute("name"); if (channelType == ChannelType.channelUC) { setting.AppId = item.GetAttribute("cpId"); setting.AppKey = item.GetAttribute("apiKey"); } else { setting.AppId = item.GetAttribute("appId"); setting.AppKey = item.GetAttribute("appKey"); } setting.AppSecret = item.GetAttribute("appSecret"); setting.GameId = item.GetAttribute("gameId"); setting.ServerId = item.GetAttribute("serverId"); gameChannel.Add(setting); } if (!_sdkChannelDict.ContainsKey(gameChannel.ChannelType)) { _sdkChannelDict.Add(gameChannel.ChannelType, gameChannel); } } }