public HttpResponseMessage GetCountries(string gameId, string saveName) { var fileName = Path.Combine(saveGamesPath, gameId, saveName); if (System.IO.File.Exists(fileName) == false) { Response.StatusCode = 404; return(null); } var content = Stellaris.GetGameSaveContent(fileName); var analyst = new Analyst(content); var countries = analyst.GetCountries(); GC.Collect(); memoryCache.GetOrUpdateTag0IsMachineEmpire(true, () => countries[0].IsMachineEmpire, () => analyst.GetInGameDate()); string json = JsonConvert.SerializeObject(countries, new JsonSerializerSettings { ContractResolver = new SerializePopContractResolver(), Formatting = serializerSettings.Formatting }); var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK); #pragma warning disable DF0022 // Marks undisposed objects assinged to a property, originated in an object creation. response.Content = new StringContent(json); #pragma warning restore DF0022 // Marks undisposed objects assinged to a property, originated in an object creation. return(response); }