rodrigovaz
rodrigovaz
CC#
Created by Alex on 3/11/2024 in #help
✅ Configure base address in HttpClient in Dependency Injection
Yeah, I attempted to reproduce the error here and couldn't get it too
82 replies
CC#
Created by Alex on 3/11/2024 in #help
✅ Configure base address in HttpClient in Dependency Injection
No description
82 replies
CC#
Created by Alex on 3/11/2024 in #help
✅ Configure base address in HttpClient in Dependency Injection
return an action that instantiates the HttpMessageHandler with automatic decompression
82 replies
CC#
Created by Alex on 3/11/2024 in #help
✅ Configure base address in HttpClient in Dependency Injection
For the automatic decompression, use the extension method ConfigurePrimaryHttpMessageHandler after you do AddHttpClient<>
82 replies
CC#
Created by Alex on 3/11/2024 in #help
✅ Configure base address in HttpClient in Dependency Injection
Microsoft does it in their examples: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-8.0#typed-clients
public class GitHubService
{
private readonly HttpClient _httpClient;

public GitHubService(HttpClient httpClient)
{
_httpClient = httpClient;

_httpClient.BaseAddress = new Uri("https://api.github.com/");

// using Microsoft.Net.Http.Headers;
// The GitHub API requires two headers.
_httpClient.DefaultRequestHeaders.Add(
HeaderNames.Accept, "application/vnd.github.v3+json");
_httpClient.DefaultRequestHeaders.Add(
HeaderNames.UserAgent, "HttpRequestsSample");
}

public async Task<IEnumerable<GitHubBranch>?> GetAspNetCoreDocsBranchesAsync() =>
await _httpClient.GetFromJsonAsync<IEnumerable<GitHubBranch>>(
"repos/dotnet/AspNetCore.Docs/branches");
}
public class GitHubService
{
private readonly HttpClient _httpClient;

public GitHubService(HttpClient httpClient)
{
_httpClient = httpClient;

_httpClient.BaseAddress = new Uri("https://api.github.com/");

// using Microsoft.Net.Http.Headers;
// The GitHub API requires two headers.
_httpClient.DefaultRequestHeaders.Add(
HeaderNames.Accept, "application/vnd.github.v3+json");
_httpClient.DefaultRequestHeaders.Add(
HeaderNames.UserAgent, "HttpRequestsSample");
}

public async Task<IEnumerable<GitHubBranch>?> GetAspNetCoreDocsBranchesAsync() =>
await _httpClient.GetFromJsonAsync<IEnumerable<GitHubBranch>>(
"repos/dotnet/AspNetCore.Docs/branches");
}
82 replies
CC#
Created by Alex on 3/11/2024 in #help
✅ Configure base address in HttpClient in Dependency Injection
As long as the HttpClient being supplied is transient, there's no downside
82 replies
CC#
Created by Alex on 3/11/2024 in #help
✅ Configure base address in HttpClient in Dependency Injection
Nonetheless, this is ok
82 replies
CC#
Created by Alex on 3/11/2024 in #help
✅ Configure base address in HttpClient in Dependency Injection
afaik, your configuration here seems right, Maybe if you show the rest of your program/startup.cs there might be something weird going on there and would be easier to troubleshoot
82 replies
CC#
Created by Thinker on 9/25/2023 in #help
✅ What's the point of MediatR?
I really like that in their GitHub page it says "Simple mediator implementation in .NET"
128 replies
CC#
Created by Thinker on 9/25/2023 in #help
✅ What's the point of MediatR?
It isn't, it was more of a heads up that the library does much more than simply helping implementing CQRS. I had the same question once and my doubt arose from looking at open source projects that used it for CQRS
128 replies
CC#
Created by Thinker on 9/25/2023 in #help
✅ What's the point of MediatR?
I meant that you will see the MediatR library in the wild a lot of times because people wanted to implement CQRS (which benefits from using the mediator pattern) and the internet is filled with "implementing CQRS with MediatR" tutorials
128 replies
CC#
Created by Thinker on 9/25/2023 in #help
✅ What's the point of MediatR?
Not reinventing the wheel
128 replies
CC#
Created by Thinker on 9/25/2023 in #help
✅ What's the point of MediatR?
Another point, a lot of people use MediatR to implement CQRS and not necessarily the Mediator pattern in itself
128 replies
CC#
Created by JakenVeina on 9/24/2023 in #help
❔ WPF Usability/Design Opinions
Maybe have a specific flow to create a sub category and include all child nodes to it automatically?
12 replies
CC#
Created by JakenVeina on 9/24/2023 in #help
❔ WPF Usability/Design Opinions
I don't think so, IMO the "worst" is the restriction on no ledgers at same level as a sub-category because that creates a problem: What if I created N ledgers and decided that it would be best to separate in 2 sub categories, what do I do with the N ledgers? Do I move tem by hand to another category just to create the subcategories? Do I delete them to then recreate them by hand?
12 replies