Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from Zastai/update-support-libraries
Update support libraries (and drop `QueryException`)
- Loading branch information
Showing
95 changed files
with
2,048 additions
and
2,048 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
MetaBrainz.MusicBrainz/Json/Readers/AuthorizationErrorReader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
|
||
using MetaBrainz.Common.Json; | ||
using MetaBrainz.Common.Json.Converters; | ||
using MetaBrainz.MusicBrainz.Objects; | ||
|
||
namespace MetaBrainz.MusicBrainz.Json.Readers; | ||
|
||
internal sealed class AuthorizationErrorReader : ObjectReader<AuthorizationError> { | ||
|
||
public static readonly AuthorizationErrorReader Instance = new(); | ||
|
||
protected override AuthorizationError ReadObjectContents(ref Utf8JsonReader reader, JsonSerializerOptions options) { | ||
string? error = null; | ||
string? description = null; | ||
Dictionary<string, object?>? rest = null; | ||
while (reader.TokenType == JsonTokenType.PropertyName) { | ||
var prop = reader.GetPropertyName(); | ||
try { | ||
reader.Read(); | ||
switch (prop) { | ||
case "error": | ||
error = reader.GetString(); | ||
break; | ||
case "error_description": | ||
description = reader.GetString(); | ||
break; | ||
default: | ||
rest ??= new Dictionary<string, object?>(); | ||
rest[prop] = reader.GetOptionalObject(options); | ||
break; | ||
} | ||
} | ||
catch (Exception e) { | ||
throw new JsonException($"Failed to deserialize the '{prop}' property.", e); | ||
} | ||
reader.Read(); | ||
} | ||
return new AuthorizationError { | ||
Error = error, | ||
Description = description, | ||
UnhandledProperties = rest | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
MetaBrainz.MusicBrainz/Json/Readers/MessageResultReader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
|
||
using MetaBrainz.Common.Json; | ||
using MetaBrainz.Common.Json.Converters; | ||
using MetaBrainz.MusicBrainz.Objects; | ||
|
||
namespace MetaBrainz.MusicBrainz.Json.Readers; | ||
|
||
internal sealed class MessageResultReader : ObjectReader<MessageResult> { | ||
|
||
public static readonly MessageResultReader Instance = new(); | ||
|
||
protected override MessageResult ReadObjectContents(ref Utf8JsonReader reader, JsonSerializerOptions options) { | ||
string? message = null; | ||
Dictionary<string, object?>? rest = null; | ||
while (reader.TokenType == JsonTokenType.PropertyName) { | ||
var prop = reader.GetPropertyName(); | ||
try { | ||
reader.Read(); | ||
switch (prop) { | ||
case "message": | ||
message = reader.GetString(); | ||
break; | ||
default: | ||
rest ??= new Dictionary<string, object?>(); | ||
rest[prop] = reader.GetOptionalObject(options); | ||
break; | ||
} | ||
} | ||
catch (Exception e) { | ||
throw new JsonException($"Failed to deserialize the '{prop}' property.", e); | ||
} | ||
reader.Read(); | ||
} | ||
return new MessageResult { | ||
Message = message, | ||
UnhandledProperties = rest | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.