This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Data.SqlClient; | |
using BenchmarkDotNet.Attributes; | |
using Bogus.DataSets; | |
using Bogus.Extensions.Brazil; | |
using Dapper.Contrib.Extensions; | |
using BenchmarkingDapperEFCoreCRM.EFCore; | |
namespace BenchmarkingDapperEFCoreCRM.Tests; | |
[SimpleJob(BenchmarkDotNet.Engines.RunStrategy.Throughput, launchCount: 5)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Frozen; | |
using System.Runtime.InteropServices; | |
using System.Text.Json; | |
Console.WriteLine("***** Testes com .NET 8 | Colecoes imutaveis com FrozenSet *****"); | |
Console.WriteLine($"Versao do .NET em uso: {RuntimeInformation | |
.FrameworkDescription} - Ambiente: {Environment.MachineName} - Kernel: {Environment | |
.OSVersion.VersionString}"); | |
var campeoesMundiais = new HashSet<string>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.InteropServices; | |
using System.Text.Json; | |
using ConsoleAppJsonNamingPolicy.Models; | |
Console.WriteLine("***** Testes com .NET 8 | Serializacao usando snake_case e kebab-case *****"); | |
Console.WriteLine($"Versao do .NET em uso: {RuntimeInformation | |
.FrameworkDescription} - Ambiente: {Environment.MachineName} - Kernel: {Environment | |
.OSVersion.VersionString}"); | |
var localidades = new Localidade[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ConsoleAppJsonNamingPolicy.Models; | |
public class Localidade | |
{ | |
public int Id { get; set; } | |
public string? NomeContinente { get; set; } | |
public string? NomePais { get; set; } | |
public string? NomeCidade { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ConsoleAppInterfaceHierarchies.Models; | |
using System.Runtime.InteropServices; | |
using System.Text.Json; | |
Console.WriteLine("***** Testes com .NET 8 | Serializacao usando Interface Hierarchies *****"); | |
Console.WriteLine($"Versao do .NET em uso: {RuntimeInformation | |
.FrameworkDescription} - Ambiente: {Environment.MachineName} - Kernel: {Environment | |
.OSVersion.VersionString}"); | |
var localidades = new Localidade[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var localidades = new Localidade[] | |
{ | |
new () { NomeCidade = "Sao Paulo", NomePais = "Brasil", NomeContinente = "America do Sul" }, | |
new () { NomeCidade = "Roma", NomePais = "Italia", NomeContinente = "Europa" }, | |
new () { NomeCidade = "Toquio", NomePais = "Japao", NomeContinente = "Asia" } | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (var cidade in localidades) | |
{ | |
Console.WriteLine(); | |
ExibirInfoLocalidade<IContinente>(cidade); | |
ExibirInfoLocalidade<IPais>(cidade); | |
ExibirInfoLocalidade<ICidade>(cidade); | |
} | |
static void ExibirInfoLocalidade<T>(T cidade) => | |
Console.WriteLine($"{typeof(T).Name} = {JsonSerializer.Serialize<T>(cidade)}"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ConsoleAppInterfaceHierarchies.Models; | |
public interface IContinente | |
{ | |
public string? NomeContinente { get; set; } | |
} | |
public interface IPais : IContinente | |
{ | |
public string? NomePais { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using APIInjDependencias.Interfaces; | |
using APIInjDependencias.Models; | |
using Microsoft.AspNetCore.Mvc; | |
namespace APIInjDependencias.Controllers | |
{ | |
[ApiController] | |
[Route("[controller]")] | |
public class ScopedController : ControllerBase | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using APIInjDependencias.Interfaces; | |
using APIInjDependencias.Models; | |
using Microsoft.AspNetCore.Mvc; | |
namespace APIInjDependencias.Controllers | |
{ | |
[ApiController] | |
[Route("[controller]")] | |
public class SingletonController : ControllerBase | |
{ |