public async Task<ActionResult> Index(string language)
{
if (String.IsNullOrWhiteSpace(language) == false)
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(language);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(language);
}
else if (String.IsNullOrWhiteSpace(language))
{
string userIpAddress = this.Request.UserHostAddress;
var client = new HttpClient
{
BaseAddress = new Uri("http://freegeoip.net/xml/")
};
var response = await client.GetAsync(userIpAddress);
var content = await response.Content.ReadAsStringAsync();
var result = (Response)new XmlSerializer(typeof(Response)).Deserialize(new StringReader(content));
// do stuff
}
...
}
[XmlRoot(ElementName = "Response")]
public class Response
{
[XmlElement(ElementName = "IP")]
public string IP { get; set; }
[XmlElement(ElementName = "CountryCode")]
public string CountryCode { get; set; }
[XmlElement(ElementName = "CountryName")]
public string CountryName { get; set; }
[XmlElement(ElementName = "RegionCode")]
public string RegionCode { get; set; }
[XmlElement(ElementName = "RegionName")]
public string RegionName { get; set; }
[XmlElement(ElementName = "City")]
public string City { get; set; }
[XmlElement(ElementName = "ZipCode")]
public string ZipCode { get; set; }
[XmlElement(ElementName = "TimeZone")]
public string TimeZone { get; set; }
[XmlElement(ElementName = "Latitude")]
public string Latitude { get; set; }
[XmlElement(ElementName = "Longitude")]
public string Longitude { get; set; }
[XmlElement(ElementName = "MetroCode")]
public string MetroCode { get; set; }
}
我正在为我的学校项目做这件事,而我无法解决的问题。 在此先感谢您的帮助:)
答案 0 :(得分:-2)
我认为,如果不使用std :: unique_ptr或std :: array做太多工作,这样的事情会很有用:
#include <vector>
...
class Baza
{
public:
std::vector<Zadanie*> my_vector;
};
...
int main(void)
{
Baza my_baza;
// Remember to properly destroy objects if you plan to
// use this approach without memory leaks!
my_baza.my_vector.push_back(new ZadanieTekst(//Insert Params//));
my_baza.my_vector.push_back(new ZadanieNumer(//Insert Params//));
my_baza.my_vector.push_back(new Zadanie4Odp(//Insert Params//));
...
return 0;
}