Skip to content

Commit

Permalink
fix: improve readability of c# example code (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erick-Bueno authored Sep 13, 2024
1 parent 839f582 commit 3d3bf32
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
9 changes: 3 additions & 6 deletions examples/dotnet/ConsoleApp.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BancosBrasileiros" Version="5.0.12" />
<PackageReference Include="BancosBrasileiros" Version="5.0.12"/>
</ItemGroup>

</Project>
</Project>
27 changes: 14 additions & 13 deletions examples/dotnet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ namespace ConsoleApp

class Program
{
private static string fileContent = System.IO.File.ReadAllText("banks.json");
private static string fileContent = System.IO.File.ReadAllText("../../data/bancos.json");
private static List<Bank> banks = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Bank>>(
fileContent
);

static void Main()
{
Console.WriteLine("Hello World!");
ShowBanks();
var compe = GetCompeFromUser();
FilterBanks(compe);
}
private static string GetCompeFromUser(){
Console.Write("Buscar COMPE (3 dígitos): ");
return Console.ReadLine();
}
private static void ShowBanks(){
Console.WriteLine($"Banks: {banks.Count}");
foreach (var bank in banks)
{
Expand All @@ -29,13 +37,7 @@ static void Main()
Console.WriteLine($"\tPortabilidade: {bank.SalaryPortability ?? "False"}");
Console.WriteLine($"\tAtualizado em: {bank.DateUpdated}\n");
}

Console.Write("Buscar COMPE (3 dígitos): ");
var compe = Console.ReadLine();

FilterBanks(compe);
}

private static void FilterBanks(string compe)
{
Console.Clear();
Expand All @@ -57,12 +59,11 @@ private static void FilterBanks(string compe)
Console.WriteLine($"\tPortabilidade: {bank.SalaryPortability ?? "False"}");
Console.WriteLine($"\tAtualizado em: {bank.DateUpdated} \n");
}
return;
}
else
{
Console.WriteLine("Nenhum Resultado Encontrado.");
}



Console.WriteLine("Nenhum Resultado Encontrado.");
Console.Write("1.Listar Todos \t 2.Buscar COMPE: ");
int option = Convert.ToInt32(Console.ReadLine());

Expand Down

0 comments on commit 3d3bf32

Please sign in to comment.