Files
WotBlitzStatisticsBlazor/WotBlitzStatisticsPro.Blazor/Generated/State/FindPlayersBuilder.WotBlitzStatisticsProClient.StrawberryShake.cs
T

157 lines
10 KiB
C#

// <auto-generated/>
#nullable enable
namespace WotBlitzStatisticsPro.Blazor.GraphQl.State
{
[global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "12.12.1.0")]
public partial class FindPlayersBuilder : global::StrawberryShake.IOperationResultBuilder<global::System.Text.Json.JsonDocument, global::WotBlitzStatisticsPro.Blazor.GraphQl.IFindPlayersResult>
{
private readonly global::StrawberryShake.IEntityStore _entityStore;
private readonly global::StrawberryShake.IEntityIdSerializer _idSerializer;
private readonly global::StrawberryShake.IOperationResultDataFactory<global::WotBlitzStatisticsPro.Blazor.GraphQl.IFindPlayersResult> _resultDataFactory;
private readonly global::StrawberryShake.Serialization.ILeafValueParser<global::System.String, global::WotBlitzStatisticsPro.Blazor.GraphQl.RealmType> _realmTypeParser;
private readonly global::StrawberryShake.Serialization.ILeafValueParser<global::System.String, global::WotBlitzStatisticsPro.Blazor.GraphQl.RequestLanguage> _requestLanguageParser;
private readonly global::StrawberryShake.Serialization.ILeafValueParser<global::System.String, global::System.String> _stringParser;
private readonly global::StrawberryShake.Serialization.ILeafValueParser<global::System.Int64, global::System.Int64> _longParser;
private readonly global::StrawberryShake.Serialization.ILeafValueParser<global::System.String, global::System.DateTimeOffset> _dateTimeParser;
private readonly global::StrawberryShake.Serialization.ILeafValueParser<global::System.Int32, global::System.Int32> _intParser;
public FindPlayersBuilder(global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityIdSerializer idSerializer, global::StrawberryShake.IOperationResultDataFactory<global::WotBlitzStatisticsPro.Blazor.GraphQl.IFindPlayersResult> resultDataFactory, global::StrawberryShake.Serialization.ISerializerResolver serializerResolver)
{
_entityStore = entityStore ?? throw new global::System.ArgumentNullException(nameof(entityStore));
_idSerializer = idSerializer ?? throw new global::System.ArgumentNullException(nameof(idSerializer));
_resultDataFactory = resultDataFactory ?? throw new global::System.ArgumentNullException(nameof(resultDataFactory));
_realmTypeParser = serializerResolver.GetLeafValueParser<global::System.String, global::WotBlitzStatisticsPro.Blazor.GraphQl.RealmType>("RealmType") ?? throw new global::System.ArgumentException("No serializer for type `RealmType` found.");
_requestLanguageParser = serializerResolver.GetLeafValueParser<global::System.String, global::WotBlitzStatisticsPro.Blazor.GraphQl.RequestLanguage>("RequestLanguage") ?? throw new global::System.ArgumentException("No serializer for type `RequestLanguage` found.");
_stringParser = serializerResolver.GetLeafValueParser<global::System.String, global::System.String>("String") ?? throw new global::System.ArgumentException("No serializer for type `String` found.");
_longParser = serializerResolver.GetLeafValueParser<global::System.Int64, global::System.Int64>("Long") ?? throw new global::System.ArgumentException("No serializer for type `Long` found.");
_dateTimeParser = serializerResolver.GetLeafValueParser<global::System.String, global::System.DateTimeOffset>("DateTime") ?? throw new global::System.ArgumentException("No serializer for type `DateTime` found.");
_intParser = serializerResolver.GetLeafValueParser<global::System.Int32, global::System.Int32>("Int") ?? throw new global::System.ArgumentException("No serializer for type `Int` found.");
}
public global::StrawberryShake.IOperationResult<IFindPlayersResult> Build(global::StrawberryShake.Response<global::System.Text.Json.JsonDocument> response)
{
(IFindPlayersResult Result, FindPlayersResultInfo Info)? data = null;
global::System.Collections.Generic.IReadOnlyList<global::StrawberryShake.IClientError>? errors = null;
if (response.Exception is null)
{
try
{
if (response.Body != null)
{
if (response.Body.RootElement.TryGetProperty("data", out global::System.Text.Json.JsonElement dataElement) && dataElement.ValueKind == global::System.Text.Json.JsonValueKind.Object)
{
data = BuildData(dataElement);
}
if (response.Body.RootElement.TryGetProperty("errors", out global::System.Text.Json.JsonElement errorsElement))
{
errors = global::StrawberryShake.Json.JsonErrorParser.ParseErrors(errorsElement);
}
}
}
catch (global::System.Exception ex)
{
errors = new global::StrawberryShake.IClientError[]{new global::StrawberryShake.ClientError(ex.Message, exception: ex, extensions: new global::System.Collections.Generic.Dictionary<global::System.String, global::System.Object?>{{"body", response.Body?.RootElement.ToString()}})};
}
}
else
{
if (response.Body != null && response.Body.RootElement.TryGetProperty("errors", out global::System.Text.Json.JsonElement errorsElement))
{
errors = global::StrawberryShake.Json.JsonErrorParser.ParseErrors(errorsElement);
}
else
{
errors = new global::StrawberryShake.IClientError[]{new global::StrawberryShake.ClientError(response.Exception.Message, exception: response.Exception, extensions: new global::System.Collections.Generic.Dictionary<global::System.String, global::System.Object?>{{"body", response.Body?.RootElement.ToString()}})};
}
}
return new global::StrawberryShake.OperationResult<IFindPlayersResult>(data?.Result, data?.Info, _resultDataFactory, errors);
}
private (IFindPlayersResult, FindPlayersResultInfo) BuildData(global::System.Text.Json.JsonElement obj)
{
var entityIds = new global::System.Collections.Generic.HashSet<global::StrawberryShake.EntityId>();
global::StrawberryShake.IEntityStoreSnapshot snapshot = default !;
_entityStore.Update(session =>
{
snapshot = session.CurrentSnapshot;
});
var resultInfo = new FindPlayersResultInfo(DeserializeIFindPlayers_PlayersNonNullableArray(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "players")), entityIds, snapshot.Version);
return (_resultDataFactory.Create(resultInfo), resultInfo);
}
private global::System.Collections.Generic.IReadOnlyList<global::WotBlitzStatisticsPro.Blazor.GraphQl.State.AccountsSearchResponseItemData>? DeserializeIFindPlayers_PlayersNonNullableArray(global::System.Text.Json.JsonElement? obj)
{
if (!obj.HasValue)
{
return null;
}
var accountsSearchResponseItems = new global::System.Collections.Generic.List<global::WotBlitzStatisticsPro.Blazor.GraphQl.State.AccountsSearchResponseItemData>();
foreach (global::System.Text.Json.JsonElement child in obj.Value.EnumerateArray())
{
accountsSearchResponseItems.Add(DeserializeNonNullableIFindPlayers_Players(child));
}
return accountsSearchResponseItems;
}
private global::WotBlitzStatisticsPro.Blazor.GraphQl.State.AccountsSearchResponseItemData DeserializeNonNullableIFindPlayers_Players(global::System.Text.Json.JsonElement? obj)
{
if (!obj.HasValue)
{
throw new global::System.ArgumentNullException();
}
var typename = obj.Value.GetProperty("__typename").GetString();
if (typename?.Equals("AccountsSearchResponseItem", global::System.StringComparison.Ordinal) ?? false)
{
return new global::WotBlitzStatisticsPro.Blazor.GraphQl.State.AccountsSearchResponseItemData(typename, accountId: DeserializeNonNullableInt64(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "accountId")), nickname: DeserializeString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "nickname")), clanTag: DeserializeString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "clanTag")), lastBattle: DeserializeNonNullableDateTimeOffset(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "lastBattle")), battlesCount: DeserializeNonNullableInt64(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "battlesCount")), winRate: DeserializeNonNullableInt32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "winRate")));
}
throw new global::System.NotSupportedException();
}
private global::System.Int64 DeserializeNonNullableInt64(global::System.Text.Json.JsonElement? obj)
{
if (!obj.HasValue)
{
throw new global::System.ArgumentNullException();
}
return _longParser.Parse(obj.Value.GetInt64()!);
}
private global::System.String? DeserializeString(global::System.Text.Json.JsonElement? obj)
{
if (!obj.HasValue)
{
return null;
}
return _stringParser.Parse(obj.Value.GetString()!);
}
private global::System.DateTimeOffset DeserializeNonNullableDateTimeOffset(global::System.Text.Json.JsonElement? obj)
{
if (!obj.HasValue)
{
throw new global::System.ArgumentNullException();
}
return _dateTimeParser.Parse(obj.Value.GetString()!);
}
private global::System.Int32 DeserializeNonNullableInt32(global::System.Text.Json.JsonElement? obj)
{
if (!obj.HasValue)
{
throw new global::System.ArgumentNullException();
}
return _intParser.Parse(obj.Value.GetInt32()!);
}
}
}