示例#1
0
        // https://dry-cliffs-19849.herokuapp.com/users.json
        // https://dry-cliffs-19849.herokuapp.com/users/2.json
        private void cmdBtn_Click(object sender, EventArgs e)
        {
            HttpRestClient client = new HttpRestClient();

            client.EndPoint = txtRequest.Text;

            debugOutput("REST Client Created");

            string strResp = string.Empty;

            strResp = client.MakeRequest();

            if (formatChkBox.Checked == true && client.EndPoint.Contains(".json"))
            {
                debugOutput(strResp.FormatJson());
                return;
            }

            debugOutput(strResp);
        }
示例#2
0
 static void Main(string[] args)
 {
     try
     {
         IRestClient client = new HttpRestClient();
         //This will come from DI in real world
         IWeatherAdapter _weaterAdapter = new WeatherDataAdapter(client);
         //Comment end
         UriBuilder     builder    = new UriBuilder();
         UriBuilderRest objbuilder = new UriBuilderRest();
         builder = objbuilder.UriBuilder();
         var     json    = _weaterAdapter.GetWeatherData(builder.Uri);
         JObject jsonObj = JObject.Parse(json);
         var     list    = from c in jsonObj["list"]
                           select c;
         Utility.PrintOutput(list);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }