From cd89c107945467684cbeaf4a656e96b2bffd1764 Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Sat, 22 Feb 2014 17:28:02 +0100 Subject: [PATCH] RemoteAgents Mono GTK Linux: Receiving null when nothing useful arrived. default(TResult) Specifies the default value of the type parameter. This will be null for reference types and zero for value types. --- Mono/RemoteAgents/GTKLinux/MainWindow.cs | 6 +++++- Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Mono/RemoteAgents/GTKLinux/MainWindow.cs b/Mono/RemoteAgents/GTKLinux/MainWindow.cs index 22371ca..7fb8be7 100644 --- a/Mono/RemoteAgents/GTKLinux/MainWindow.cs +++ b/Mono/RemoteAgents/GTKLinux/MainWindow.cs @@ -34,7 +34,11 @@ namespace Example.RemoteAgents.GTKLinux async private void ButtonGetDateClicked(object sender, EventArgs a) { - this.RemoteDate.Buffer.Text = await view.getCurrentDate(); + string currentDate = await view.getCurrentDate(); + if (currentDate != null) + { + this.RemoteDate.Buffer.Text = currentDate; + } } } } diff --git a/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs b/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs index 27572ea..f67879c 100644 --- a/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs +++ b/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs @@ -16,8 +16,7 @@ namespace Example.RemoteAgents.GTKLinux.Model async public Task callRemoteService(string uri, string method) { - TResult result = default(TResult); - POST postData = new POST(); + var postData = new POST(); postData.Id = "2114567586433855105"; postData.JSONrpc = "2.0"; postData.Method = method; @@ -27,6 +26,8 @@ namespace Example.RemoteAgents.GTKLinux.Model HttpResponseMessage response = await this.issueCall(uri, content); + TResult result = default(TResult); + if (response.StatusCode == HttpStatusCode.OK) { Task responseBytes = response.Content.ReadAsByteArrayAsync(); string responseString = System.Text.Encoding.UTF8.GetString(responseBytes.Result); -- 2.1.4