-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
542: Add `Unknown` type to `TaskInfoType` r=curquiza a=postmeback # Pull Request ## Related issue Fixes #385 ## What does this PR do? - Currently, it adds the "Unknown" type to the enum. It requires more tasks to do ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: postmeback <[email protected]> Co-authored-by: Clémentine <[email protected]> Co-authored-by: Ahmed Fwela <[email protected]> Co-authored-by: Arka Poddar <[email protected]>
- Loading branch information
Showing
4 changed files
with
68 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Meilisearch.Converters | ||
{ | ||
public class TaskInfoTypeConverter : JsonConverter<TaskInfoType> | ||
{ | ||
public override TaskInfoType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
if (reader.TokenType == JsonTokenType.String) | ||
{ | ||
var enumValue = reader.GetString(); | ||
if (Enum.TryParse<TaskInfoType>(enumValue, true, out var taskInfoType)) | ||
{ | ||
return taskInfoType; | ||
} | ||
} | ||
|
||
// If we reach here, it means we encountered an unknown value | ||
return TaskInfoType.Unknown; | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, TaskInfoType value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.ToString()); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -425,5 +425,6 @@ private TaskEndpoint TaskEndpoint() | |
|
||
return _taskEndpoint; | ||
} | ||
|
||
} | ||
} |
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