public static QueueMessage FromByteArray(byte[] body) { using (var wcfClient = new StockServiceClient()) { var result = wcfClient.FromByteArray(body); wcfClient.Close(); return(result); } }
public static async Task SendCodeMessage(string message, string userName) { using (var wcfClient = new StockServiceClient()) { await wcfClient.SendMessageAsync(message, "request", "response", userName); wcfClient.Close(); } }
static void Main() { StockServiceClient proxy = new StockServiceClient(); double p = proxy.GetPrice("msft"); Console.WriteLine("Price:{0}", p); Console.ReadKey(); proxy.Close(); }
static void Main(string[] args) { string ticker = "IBM"; Console.WriteLine("Asking for {0}", ticker); StockServiceClient proxy = new StockServiceClient(); Console.ReadLine(); do { Info info = proxy.GetStockPrice(ticker); Console.WriteLine("Response: name = {0} value = {1:F2}", info.name, info.value); Console.WriteLine("(A)gain ?"); } while (Console.ReadKey(true).KeyChar == 'a'); proxy.Close(); }
public static void SendStockMessage(QueueMessage queueMessage, string queue) { using (var wcfClient = new StockServiceClient()) { var stock = wcfClient.GetStock(queueMessage.Message); if (stock.Success) { wcfClient.SendMessageAsync($"{stock.Symbol} quote is {stock.CloseTyped.ToString("C2")} per share", queue, null, queueMessage.UserName); } else { wcfClient.SendMessageAsync(stock.ErrorMessage, queue, null, queueMessage.UserName); } wcfClient.Close(); } }