private void ExecuteSelecionarRespostaCommand(ProjetoItemDto dto)
        {
            var parameters = new DialogParameters();

            parameters.Add("detalhe", dto);
            _dialogService.ShowDialog("ProjetoItemDialogPage", parameters, result =>
            {
            });
        }
            static void ProcessarHeaderResposta(HttpContext context, ProjetoItemDto endpoint)
            {
                if (string.IsNullOrWhiteSpace(endpoint.RespostaHeader))
                {
                    return;
                }
                var headers = endpoint.RespostaHeader.Split("&", StringSplitOptions.RemoveEmptyEntries);

                if (headers.Length > 0)
                {
                    foreach (var item in headers)
                    {
                        var value = item.Split('=', StringSplitOptions.RemoveEmptyEntries);
                        context.Response.Headers[value[0]] = value[1];
                    }
                }
            }
        private async Task ProcessarRequisicao(HttpContext context, ProjetoItemDto endpoint)
        {
            if (endpoint.Respostas?.Count > 0)
            {
                var respostasComCondicoes = endpoint.Respostas.Where(x => x.Condicao != null);
                if (respostasComCondicoes.Count() == 0)
                {
                    ProcessarHeaderResposta(context, endpoint);
                    var resposta = endpoint.Respostas.OrderBy(x => Guid.NewGuid()).FirstOrDefault();
                    context.Response.StatusCode = resposta.CodigoHttp;
                    await context.Response.WriteAsync(await ProcessarResposta(context, resposta));
                }
                else
                {
                    ProcessarHeaderResposta(context, endpoint);
                    //tpRequisicao=6
                    //idRequisicao=xxxxxxx
                    var query = context.Request.Query.Select(x => $"#query-{x.Key}#={x.Value}").ToList();

                    //Condicoes
                    //#query-tpRequisicao#=6
                    var resposta = endpoint.Respostas.Where(x => query.Contains(x.Condicao)).FirstOrDefault();

                    //Achamos na query
                    if (resposta != null)
                    {
                        context.Response.StatusCode = resposta.CodigoHttp;
                        await context.Response.WriteAsync(await ProcessarResposta(context, resposta));
                    }
                    else
                    {
                        //Tentaremos no header
                        var header         = context.Request.Headers.Select(x => $"#header-{x.Key}#={x.Value}").ToList();
                        var respostaHeader = endpoint.Respostas.Where(x => header.Contains(x.Condicao)).FirstOrDefault();

                        if (respostaHeader != null)
                        {
                            context.Response.StatusCode = resposta.CodigoHttp;
                            await context.Response.WriteAsync(await ProcessarResposta(context, resposta));
                        }
                        else
                        {
                            var respostaSemCondicoes = endpoint.Respostas.Where(x => x.Condicao == null).OrderBy(x => Guid.NewGuid()).FirstOrDefault();
                            if (respostasComCondicoes == null)
                            {
                                context.Response.StatusCode = resposta.CodigoHttp;
                                await context.Response.WriteAsync(await ProcessarResposta(context, respostaSemCondicoes));
                            }
                            else
                            {
                                context.Response.StatusCode = 500;
                                await context.Response.WriteAsync("Falhamos miseravelmente em processar sua requisição.");
                            }
                        }
                    }
                }
            }
            else
            {
                ProcessarHeaderResposta(context, endpoint);
                context.Response.StatusCode = endpoint.CodigoHttpPadrao;
                await context.Response.WriteAsync(await ProcessarResposta(context, endpoint.RespostaPadrao));
            }

            if (endpoint.Projeto.ExibirLog)
            {
                var sb = new StringBuilder();
                using var stream = new StreamReader(context.Request.Body);


                var metodo = endpoint.Metodo switch
                {
                    MetodoHttp.MhDelete => "DELETE",
                    MetodoHttp.MhGet => "GET",
                    MetodoHttp.MhPatch => "PATCH",
                    MetodoHttp.MhPost => "POST",
                    MetodoHttp.MhPut => "PUT",
                    _ => "MÉTODO DESCONHECIDO"
                };

                sb.AppendLine($"{metodo} {context.Request.GetEncodedUrl()}");
                sb.AppendLine("---------------------------------------------");


                var body = await stream.ReadToEndAsync();

                if (!string.IsNullOrWhiteSpace(body))
                {
                    sb.AppendLine("Body content");
                    sb.AppendLine("---------------------------------------------");
                    sb.AppendLine(await stream.ReadToEndAsync());
                    sb.AppendLine("---------------------------------------------");
                }

                var headers = context.Request.Headers;
                if (headers?.Count > 0)
                {
                    sb.AppendLine("Header content");
                    sb.AppendLine("---------------------------------------------");
                    foreach (var item in context.Request.Headers)
                    {
                        sb.AppendLine($"{item.Key} = {item.Value}");
                    }
                    sb.AppendLine("---------------------------------------------");
                }

                var queries = context.Request.Query;

                if (queries?.Count > 0)
                {
                    sb.AppendLine("Query content");
                    sb.AppendLine("---------------------------------------------");
                    foreach (var item in context.Request.Query)
                    {
                        sb.AppendLine($"{item.Key} = {item.Value}");
                    }
                    sb.AppendLine("---------------------------------------------");
                }

                Logs += sb.ToString();
            }
 public void OnDialogOpened(IDialogParameters parameters)
 {
     Item = parameters.GetValue <ProjetoItemDto>("detalhe");
     RaisePropertyChanged(nameof(Item));
 }