async Task <VsixResponse> Responce(VsixSend message) { switch (message.ActionType) { case ActionType.ListProjects: return(new VsixResponse(string.Join(",", await GetAllProjectsAsync()))); case ActionType.AddFile: return(new VsixResponse((await AddFileAsync(message.Parameters[0], message.Parameters[1])).ToString())); case ActionType.AddReference: return(new VsixResponse((await AddReferenceAsync(message.Parameters[0])).ToString())); default: throw new ArgumentOutOfRangeException(); } }
static async Task <VsixResponse> DoWithServerAsync(VsixSend jsonObject) { using (HttpClient client = new HttpClient()) { var content = new StringContent(JsonConvert.SerializeObject(jsonObject), Encoding.UTF8, "application/json"); var response = await client.PostAsync(serverAddress, content); if (response != null) { var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <VsixResponse>(jsonString)); } } throw new HttpRequestException("Empty response"); }