mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
43 lines
1.4 KiB
// ==========================================================================
|
|
// AppClientsConverter.cs
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex Group
|
|
// All rights reserved.
|
|
// ==========================================================================
|
|
|
|
using System.Collections.Generic;
|
|
using Newtonsoft.Json;
|
|
using Squidex.Infrastructure.Json;
|
|
|
|
namespace Squidex.Domain.Apps.Core.Apps.Json
|
|
{
|
|
public sealed class AppClientsConverter : JsonClassConverter<AppClients>
|
|
{
|
|
protected override void WriteValue(JsonWriter writer, AppClients value, JsonSerializer serializer)
|
|
{
|
|
var json = new Dictionary<string, JsonAppClient>(value.Count);
|
|
|
|
foreach (var client in value)
|
|
{
|
|
json.Add(client.Key, new JsonAppClient(client.Value));
|
|
}
|
|
|
|
serializer.Serialize(writer, json);
|
|
}
|
|
|
|
protected override AppClients ReadValue(JsonReader reader, JsonSerializer serializer)
|
|
{
|
|
var json = serializer.Deserialize<Dictionary<string, JsonAppClient>>(reader);
|
|
|
|
var clients = new AppClients();
|
|
|
|
foreach (var client in json)
|
|
{
|
|
clients.Add(client.Key, client.Value.ToClient());
|
|
}
|
|
|
|
return clients;
|
|
}
|
|
}
|
|
}
|
|
|