Created
February 27, 2016 01:19
-
-
Save DinoChiesa/9b9de8725d62647c4466 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TestWebRequest.cs | |
// ------------------------------------------------------------------ | |
// | |
// Author: Dino | |
// initialized on: Fri Feb 26 17:00:17 2016 | |
// | |
// last saved: <2016-February-26 17:19:13> | |
// ------------------------------------------------------------------ | |
// | |
// Copyright © 2016 Dino Chiesa | |
// All rights reserved. | |
// | |
// ------------------------------------------------------------------ | |
using System; | |
using System.Net; | |
using System.Web; | |
using System.IO; | |
using System.Reflection; | |
// to allow fast ngen | |
[assembly: AssemblyTitle("testme.cs")] | |
[assembly: AssemblyDescription("insert purpose here")] | |
[assembly: AssemblyConfiguration("")] | |
[assembly: AssemblyCompany("Dino Chiesa")] | |
[assembly: AssemblyProduct("Tools")] | |
[assembly: AssemblyCopyright("Copyright (c) Dino Chiesa 2010")] | |
[assembly: AssemblyTrademark("")] | |
[assembly: AssemblyCulture("")] | |
[assembly: AssemblyVersion("1.1.1.1")] | |
namespace Ionic.ToolsAndTests | |
{ | |
public class TestWebRequest | |
{ | |
int tempToConvert = 0; | |
public TestWebRequest (string[] args) | |
{ | |
if (args.Length >0) | |
{ | |
tempToConvert = Int32.Parse(args[0]); | |
} | |
} | |
public void Run() | |
{ | |
var targetUri = new Uri("https://deecee-test.apigee.net/tempconvert/ctof/" + | |
tempToConvert); | |
var webRequest = (HttpWebRequest)WebRequest.Create(targetUri); | |
using (WebResponse webResponse = webRequest.GetResponse()) | |
{ | |
using (StreamReader rd = new StreamReader(webResponse.GetResponseStream())) | |
{ | |
var x = rd.ReadToEnd(); | |
Console.WriteLine("result: " + x); | |
} | |
} | |
} | |
public static void Usage() | |
{ | |
Console.WriteLine("\nTestWebRequest: convert from celsius to Fahrenheit.\n"); | |
Console.WriteLine("Usage:\n TestWebRequest <temperature-to-convert>"); | |
} | |
public static void Main(string[] args) | |
{ | |
try | |
{ | |
new TestWebRequest(args).Run(); | |
} | |
catch (System.Exception exc1) | |
{ | |
Console.WriteLine("Exception: {0}", exc1.ToString()); | |
Usage(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment