Skip to content

Instantly share code, notes, and snippets.

View jeangatto's full-sized avatar
🏠
Working from home

Jean Francisco Flores Gatto jeangatto

🏠
Working from home
View GitHub Profile
@jeangatto
jeangatto / CurrentUserProvider.cs
Created February 6, 2023 10:55
ASP.NET Core Get Current User Provider
public interface ICurrentUserProvider
{
Guid? GetCurrentUserId();
}
public class CurrentUserProvider : ICurrentUserProvider
{
private readonly IHttpContextAccessor _httpContextAcessor;
public CurrentUserProvider(IHttpContextAccessor httpContextAcessor)
@jeangatto
jeangatto / EfTransaction.cs
Created February 6, 2023 11:00
ASP.NET Core EF Core Transaction Pipeline Behavior
public class TransactionBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
where TRequest : IRequest<TResponse>
{
private readonly ITransaction _transaction;
public TransactionBehaviour(ITransaction transaction) => _transaction = transaction;
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
{
var response = default(TResponse);
@jeangatto
jeangatto / GetAllTypesThatImplementInterface.cs
Created February 23, 2023 18:58
C# Getting all types that implement an interface
var myInterfaceTypeOf = typeof(IReadDbMapping);
var implementations = AppDomain
.CurrentDomain
.GetAssemblies()
.SelectMany(assembly => assembly.GetTypes())
.Where(type => myInterfaceTypeOf.IsAssignableFrom(type)
&& type.IsClass
&& !type.IsAbstract
&& !type.IsInterface)
@jeangatto
jeangatto / settings.json
Last active May 12, 2025 13:21
VS Code Settings (for C#)
{
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
@jeangatto
jeangatto / settings.json
Last active February 21, 2025 23:02
Windows 11 Terminal Settings
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions": [
{
"command": {
"action": "copy",
"singleLine": false
},
"id": "User.copy.644BA8F2",