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

80 lines
5.3 KiB
C#

// <auto-generated/>
#nullable enable
namespace WotBlitzStatisticsPro.Blazor.GraphQl.State
{
[global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.2.2.0")]
public partial class WargamingOpenIdBuilder : global::StrawberryShake.IOperationResultBuilder<global::System.Text.Json.JsonDocument, global::WotBlitzStatisticsPro.Blazor.GraphQl.IWargamingOpenIdResult>
{
private readonly global::StrawberryShake.IEntityStore _entityStore;
private readonly global::StrawberryShake.IEntityIdSerializer _idSerializer;
private readonly global::StrawberryShake.IOperationResultDataFactory<global::WotBlitzStatisticsPro.Blazor.GraphQl.IWargamingOpenIdResult> _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::System.String> _stringParser;
public WargamingOpenIdBuilder(global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityIdSerializer idSerializer, global::StrawberryShake.IOperationResultDataFactory<global::WotBlitzStatisticsPro.Blazor.GraphQl.IWargamingOpenIdResult> 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.");
_stringParser = serializerResolver.GetLeafValueParser<global::System.String, global::System.String>("String") ?? throw new global::System.ArgumentException("No serializer for type `String` found.");
}
public global::StrawberryShake.IOperationResult<IWargamingOpenIdResult> Build(global::StrawberryShake.Response<global::System.Text.Json.JsonDocument> response)
{
(IWargamingOpenIdResult Result, WargamingOpenIdResultInfo 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
{
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<IWargamingOpenIdResult>(data?.Result, data?.Info, _resultDataFactory, errors);
}
private (IWargamingOpenIdResult, WargamingOpenIdResultInfo) 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 WargamingOpenIdResultInfo(DeserializeNonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "logout")), entityIds, snapshot.Version);
return (_resultDataFactory.Create(resultInfo), resultInfo);
}
private global::System.String DeserializeNonNullableString(global::System.Text.Json.JsonElement? obj)
{
if (!obj.HasValue)
{
throw new global::System.ArgumentNullException();
}
return _stringParser.Parse(obj.Value.GetString()!);
}
}
}