Esempio n. 1
0
        private static List <VSWhereResult> GetResult(IProcess process, VSWhereSettings toolSettings)
        {
            if (!(toolSettings.UTF8 ?? false) || toolSettings.Format != VSWhereFormat.json || toolSettings.Property != null)
            {
                return(null);
            }

            var output = process.Output.EnsureOnlyStd().Select(x => x.Text).JoinNewLine();

            return(SerializationTasks.JsonDeserialize <VSWhereResult[]>(output).ToList());
        }
Esempio n. 2
0
        private static GitVersion GetResult(IProcess process, GitVersionSettings toolSettings)
        {
            var output = process.Output.EnsureOnlyStd().Select(x => x.Text).JoinNewLine();

            try
            {
                return(SerializationTasks.JsonDeserialize <GitVersion>(output, settings =>
                {
                    settings.ContractResolver = new AllWritableContractResolver();
                    return settings;
                }));
            }
            catch (Exception exception)
            {
                throw new Exception($"Cannot parse {nameof(GitVersion)} output:".Concat(new[] { output }).JoinNewLine(), exception);
            }
        }
Esempio n. 3
0
        private static async Task <JObject> PostMessage(string url, object message, string accessToken)
        {
            var httpHandler = new GitterTasks.AuthenticatedHttpClientHandler(accessToken);

            using var client = new HttpClient(httpHandler);

            var payload  = JsonConvert.SerializeObject(message);
            var response = await client.PostAsync(url, new StringContent(payload, Encoding.UTF8, "application/json"));

            var responseContent = await response.Content.ReadAsStringAsync();

            ControlFlow.Assert(response.StatusCode == HttpStatusCode.OK, responseContent);

            var jobject = SerializationTasks.JsonDeserialize <JObject>(responseContent);
            var error   = jobject.GetPropertyValueOrNull <string>("error");

            ControlFlow.Assert(error == null, error);
            return(jobject);
        }
Esempio n. 4
0
 public static T StdToJson <T>(this IEnumerable <Output> output)
 {
     return(SerializationTasks.JsonDeserialize <T>(output.StdToText()));
 }