From 674ca83ba9243a9e95a7568c797668dab6aee26a Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:35:25 -0300 Subject: feat: upload files --- Gestor.Application/Helpers/HttpHelper.cs | 103 +++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 Gestor.Application/Helpers/HttpHelper.cs (limited to 'Gestor.Application/Helpers/HttpHelper.cs') diff --git a/Gestor.Application/Helpers/HttpHelper.cs b/Gestor.Application/Helpers/HttpHelper.cs new file mode 100644 index 0000000..e042d1b --- /dev/null +++ b/Gestor.Application/Helpers/HttpHelper.cs @@ -0,0 +1,103 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using System.Net.Http; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace Gestor.Application.Helpers +{ + public static class HttpHelper + { + public static Uri AddQuery(this Uri uri, string name, T value) + { + // + // Current member / type: System.Uri Gestor.Application.Helpers.HttpHelper::AddQuery(System.Uri,System.String,T) + // File path: C:\AggerSeguros\Gestor.Application.exe + // + // Product version: 0.0.0.0 + // Exception in: System.Uri AddQuery(System.Uri,System.String,T) + // + // Managed pointer usage not in SSA + // at Telerik.JustDecompiler.Steps.ManagedPointersRemovalStep.CheckForAssignment(BinaryExpression node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\ManagedPointersRemovalStep.cs:line 100 + // at Telerik.JustDecompiler.Steps.ManagedPointersRemovalStep.VisitBinaryExpression(BinaryExpression node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\ManagedPointersRemovalStep.cs:line 80 + // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 351 + // at Telerik.JustDecompiler.Steps.ManagedPointersRemovalStep.VisitExpressions() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\ManagedPointersRemovalStep.cs:line 41 + // at Telerik.JustDecompiler.Steps.ManagedPointersRemovalStep.Process(DecompilationContext context, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\ManagedPointersRemovalStep.cs:line 29 + // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100 + // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72 + // at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 61 + // at Telerik.JustDecompiler.Decompiler.WriterContextServices.BaseWriterContextService.DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 133 + // + // mailto: JustDecompilePublicFeedback@telerik.com + + } + + public static Dictionary ParseQueryString(this Uri uri) + { + int num = uri.Query.IndexOf('?') + 1; + return ( + from o in uri.Query.Substring(num).Split(new char[] { '&' }) + select o.Split(new char[] { '=' }) into items + where (int)items.Length == 2 + select items).ToDictionary((string[] pair) => pair[0], (string[] pair) => pair[1]); + } + + public static Uri SetQuery(this Uri uri, string name, string value, bool escapeValue = true) + { + UriBuilder uriBuilder = new UriBuilder(uri); + Dictionary strs = uri.ParseQueryString(); + string str = (escapeValue ? Uri.EscapeDataString(value) : value); + if (strs.ContainsKey(name)) + { + strs.Remove(name); + } + strs.Add(name, str); + List list = ( + from x in strs + select string.Concat(x.Key, "=", x.Value)).ToList(); + uriBuilder.Query = string.Join("&", list); + return uriBuilder.Uri; + } + + public static string ToBase64BasicEncode(this string value) + { + return string.Concat("Basic ", Convert.ToBase64String(Encoding.UTF8.GetBytes(value))); + } + + public static StringContent ToHttpContent(this T content, Encoding encoding = null, string mediaType = "application/json") + { + return new StringContent(JsonConvert.SerializeObject(content), Encoding.UTF8, mediaType); + } + + public static JObject ToJObject(this string jsonString) + { + JObject jObject; + try + { + jObject = JObject.Parse(jsonString); + } + catch (Exception exception) + { + jObject = null; + } + return jObject; + } + + public static JObject ToJObject(this HttpContent content) + { + return content.ReadAsStringAsync().Result.ToJObject(); + } + + public static Uri ToUri(this string uri) + { + Uri uri1; + Uri.TryCreate(uri, UriKind.Absolute, out uri1); + return uri1; + } + } +} \ No newline at end of file -- cgit v1.2.3