diff --git a/cli/Squidex.CLI/Directory.Build.props b/cli/Squidex.CLI/Directory.Build.props index 7481d057..b15dd572 100644 --- a/cli/Squidex.CLI/Directory.Build.props +++ b/cli/Squidex.CLI/Directory.Build.props @@ -15,6 +15,6 @@ Squidex HeadlessCMS true snupkg - 11.2 + 11.3 diff --git a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentsClient.cs b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentsClient.cs index fb3a4b81..142cffae 100644 --- a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentsClient.cs +++ b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentsClient.cs @@ -120,10 +120,14 @@ public async Task StreamAllAsync(Func callback, int skip = 0, Que throw new SquidexException("Line does not start with data prefix."); } -#pragma warning disable IDE0057 // Use range operator - var contentJson = line.Substring(Prefix.Length); -#pragma warning restore IDE0057 // Use range operator - var contentItem = contentJson.FromJson(); + var stringReader = new StringReader(line); + + for (var i = 0; i < Prefix.Length; i++) + { + stringReader.Read(); + } + + var contentItem = stringReader.FromJson(); await callback(contentItem); } diff --git a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/SquidexOptions.cs b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/SquidexOptions.cs index 842302ed..af563f2f 100644 --- a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/SquidexOptions.cs +++ b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/SquidexOptions.cs @@ -205,6 +205,7 @@ public SquidexOptions UseFallbackSerializer() { SerializerSettings.Converters.Add(ListFallbackConverter.Clients); SerializerSettings.Converters.Add(ListFallbackConverter.Languages); + SerializerSettings.Converters.Add(ListFallbackConverter.Rules); SerializerSettings.Converters.Add(ListFallbackConverter.Schemas); return this; } diff --git a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/Utils/HttpClientExtensions.cs b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/Utils/HttpClientExtensions.cs index 8d447562..e3d5be57 100644 --- a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/Utils/HttpClientExtensions.cs +++ b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/Utils/HttpClientExtensions.cs @@ -119,6 +119,23 @@ public static T FromJson(this string value) return json; } + /// + /// Read a value from a JSON string. + /// + /// The type of the value. + /// The JSON string. + /// + /// The deserialized value. + /// + public static T FromJson(this StringReader value) + { + using var jsonReader = new JsonTextReader(value); + + var jsonSerializer = JsonSerializer.CreateDefault(SerializerSettings); + + return jsonSerializer.Deserialize(jsonReader)!; + } + /// /// Read a value from a JSON string and uses explicit type name handling. /// diff --git a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/Utils/ListFallbackConverter.cs b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/Utils/ListFallbackConverter.cs index 7bef9159..5665c693 100644 --- a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/Utils/ListFallbackConverter.cs +++ b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/Utils/ListFallbackConverter.cs @@ -33,4 +33,11 @@ internal static class ListFallbackConverter { Items = items }); + + public static readonly ListFallbackConverter Rules = + new ListFallbackConverter( + items => new RulesDto + { + Items = items + }); }