Skip to content

Commit

Permalink
💾 Feat(SyncCodes): Use static json serializer options
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed Sep 2, 2024
1 parent 05b02cc commit f9b43df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Utils/SyncCodes/FileItem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Security.Cryptography;
using System.Text;
using System.Text.Json.Serialization;

namespace SyncCodes;

Expand All @@ -9,7 +10,7 @@ public class FileItem

public string Hash { get; }

public bool FileLoaded { get; set; }
[JsonIgnore] public bool FileLoaded { get; set; }

public FileItem(string path)
{
Expand Down
13 changes: 10 additions & 3 deletions Utils/SyncCodes/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

var jsonSerializerOptions = new JsonSerializerOptions()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true,
};

Parser.Default.ParseArguments<CommandLineOptions>(args)
.WithParsed(options =>
{
Expand Down Expand Up @@ -121,7 +127,8 @@ void RunClient(Context context)
}

var catalog = JsonSerializer.Deserialize<List<FileItem>>(
await catalogResponse.Content.ReadAsStringAsync()
await catalogResponse.Content.ReadAsStringAsync(),
jsonSerializerOptions
)!;

var localCatalog = context.GetFiles();
Expand All @@ -142,8 +149,8 @@ await catalogResponse.Content.ReadAsStringAsync()
// .Select(c => new { Original = c.Original, Difference = c.New })
// ;

app.Logger.LogInformation("Need to fetch: {json}", JsonSerializer.Serialize(needToFetch));
app.Logger.LogInformation("Need to delete:: {json}", JsonSerializer.Serialize(needToDelete));
app.Logger.LogInformation("Need to fetch: {json}", JsonSerializer.Serialize(needToFetch, jsonSerializerOptions));
app.Logger.LogInformation("Need to delete:: {json}", JsonSerializer.Serialize(needToDelete, jsonSerializerOptions));
// app.Logger.LogDebug("Need to update: {json}", JsonSerializer.Serialize(needToUpdate));
};
timer.Start();
Expand Down

0 comments on commit f9b43df

Please sign in to comment.