Created
April 30, 2015 08:02
-
-
Save chukitow/127c5b2892eea4de9adc to your computer and use it in GitHub Desktop.
This file contains 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
_serialPort = new SerialPort(); | |
// Allow the user to set the appropriate properties. | |
_serialPort.PortName = SetPortName(_serialPort.PortName); | |
_serialPort.BaudRate = SetPortBaudRate(_serialPort.BaudRate); | |
_serialPort.Parity = SetPortParity(_serialPort.Parity); | |
_serialPort.DataBits = SetPortDataBits(_serialPort.DataBits); | |
_serialPort.StopBits = SetPortStopBits(_serialPort.StopBits); | |
_serialPort.Handshake = SetPortHandshake(_serialPort.Handshake); | |
_serialPort.Open(); | |
string message = _serialPort.ReadLine(); | |
//Http | |
using (var client = new HttpClient()) | |
{ | |
client.BaseAddress = new Uri("http://localhost:9000/"); | |
client.DefaultRequestHeaders.Accept.Clear(); | |
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); | |
// New code: | |
HttpResponseMessage response = await client.GetAsync("api/products/1"); | |
if (response.IsSuccessStatusCode) | |
{ | |
Product product = await response.Content.ReadAsAsync>Product>(); | |
Console.WriteLine("{0}\t${1}\t{2}", product.Name, product.Price, product.Category); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment