1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| public enum JSONQuery { GetMetrics, GetPerformances, GetLogin, GetImageList, GetDatabases, GetDistorsions, SendImages };
public class JSON
{
private string url;
WebClient wc = new WebClient();
JSONQuery query;
public JSON(string address)
{
url = address;
wc.OpenReadCompleted += new OpenReadCompletedEventHandler(OpenReadCompleted);
}
public void Request(JSONQuery q, object post)
{
switch (q)
{
case JSONQuery.GetPerformances:
query = q;
wc.OpenReadAsync(new Uri(url + "?performances"));
break;
case JSONQuery.GetDatabases:
query = q;
MessageBox.Show(url + "?databases");
wc.OpenReadAsync(new Uri(url + "?databases"));
break;
default: break;
}
}
public void OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
Stream strm = e.Result;
switch(query)
{
default: break;
}
} |