public Global() : base() { List <string> plugins = Directory.GetFiles(ConfigurationManager.AppSettings[@"GameListPluginPath"], "*.dll", SearchOption.TopDirectoryOnly).ToList(); plugins.ForEach(dr => { try { IGameListPlugin plugin = LoadAssembly(dr); GameListPlugins.Add(plugin.GameID, plugin); } catch { } }); }
private void GetGames(HttpContext context) { gamelist.CleanStaleGames(); string __gameId = context.Request.QueryString["__gameId"]; if (__gameId == null || __gameId.Length == 0) { context.Response.StatusCode = 400; // Bad Request return; } IGameListPlugin Plugin = null; ((Global)(context.ApplicationInstance)).GameListPlugins.TryGetValue(__gameId, out Plugin); NameValueCollection QueryString = context.Request.QueryString; if (Plugin != null) { Plugin.InterceptQueryStringForGet(ref QueryString); } string geoIP = QueryString["__geoIP"]; if (geoIP == null || geoIP.Length == 0) { geoIP = context.Request.UserHostAddress; } List <string> excludedColumns = new List <string>(); string strExcludedCols = QueryString["__excludeCols"]; if (strExcludedCols != null && strExcludedCols.Length > 0) { excludedColumns.AddRange(strExcludedCols.Split(',')); } JObject responseObject = new JObject(); JArray GameArray = new JArray(); responseObject["GET"] = GameArray; List <GameData> RawGames = gamelist.GetGames(__gameId); if (Plugin != null) { Plugin.PreProcessGameList(QueryString, ref RawGames); } RawGames.ForEach(dr => { JObject obj = new JObject(); if (!excludedColumns.Contains("__gameId")) { obj["__gameId"] = dr.gameId; } if (!excludedColumns.Contains("__rowId")) { obj["__rowId"] = dr.rowId; } //if (!excludedColumns.Contains("__updatePW")) obj["__updatePW"] = dr.updatePw; if (!excludedColumns.Contains("__addr")) { obj["__addr"] = dr.addr; } //if (!excludedColumns.Contains("__clientReqId")) obj["__clientReqId"] = dr.clientReqId; if (!excludedColumns.Contains("__timeoutSec")) { obj["__timeoutSec"] = dr.timeoutSec; } foreach (KeyValuePair <string, JValue> pair in dr.customValues) { if (!excludedColumns.Contains(pair.Key)) { obj[pair.Key] = pair.Value; } } GameArray.Add(obj); }); //// holdover from when the rewrite engine was used rather than directly setting this handler //if (context.Request.ServerVariables["HTTP_X_ORIGINAL_URL"] != null) //{ // responseObject["requestURL"] = context.Request.Url.GetLeftPart(UriPartial.Authority) + context.Request.ServerVariables["HTTP_X_ORIGINAL_URL"]; //} //else //{ // responseObject["requestURL"] = context.Request.Url.ToString(); //} responseObject["requestURL"] = context.Request.Url.ToString(); if (Plugin != null) { responseObject["plugin"] = Plugin.DisplayName.ToString(); } context.Response.Write(responseObject.ToString(Newtonsoft.Json.Formatting.None)); }