Exemple #1
0
        public override EtymologyLanguageElement?Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            var typeDiscriminator = TypeElementConverterHelper.GetTypeDiscriminator(ref reader);

            EtymologyLanguageElement?result;

            switch (typeDiscriminator.ToLower())
            {
            case "language":
            case "grammar":
            case "relation":
                result = JsonSerializer.Deserialize <EtymologyLanguageIdElement>(ref reader, options);
                break;

            case "usage":
                result = JsonSerializer.Deserialize <EtymologyLanguageTextElement>(ref reader, options);
                break;

            default:
                // Read and throw away object so that the reader reaches EndObject token
                _      = JsonSerializer.Deserialize <object>(ref reader, options);
                result = null;
                break;
            }

            return(result);
        }
        public override EtymologyGroup?Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            var typeDiscriminator = TypeElementConverterHelper.GetTypeDiscriminator(ref reader);

            EtymologyGroup?result;

            switch (typeDiscriminator.ToLower())
            {
            case "etymology_language":
                result = JsonSerializer.Deserialize <EtymologyLanguage>(ref reader, options);
                break;

            case "etymology_litt":
                result = JsonSerializer.Deserialize <EtymologyLitt>(ref reader, options);
                break;

            case "etymology_reference":
                result = JsonSerializer.Deserialize <EtymologyReference>(ref reader, options);
                break;

            default:
                // Read and throw away object so that the reader reaches EndObject token
                _      = JsonSerializer.Deserialize <object>(ref reader, options);
                result = null;
                break;
            }

            return(result);
        }
Exemple #3
0
        public override DefinitionElement?Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            var typeDiscriminator = TypeElementConverterHelper.GetTypeDiscriminator(ref reader);

            DefinitionElement?result;

            switch (typeDiscriminator.ToLower())
            {
            case "definition":
                result = JsonSerializer.Deserialize <Definition>(ref reader, options);
                break;

            case "explanation":
                result = JsonSerializer.Deserialize <Explanation>(ref reader, options);
                break;

            case "example":
                result = JsonSerializer.Deserialize <Example>(ref reader, options);
                break;

            case "sub_article":
                result = JsonSerializer.Deserialize <DefinitionSubArticle>(ref reader, options);
                break;

            default:
                // Read and throw away object so that the reader reaches EndObject token
                _      = JsonSerializer.Deserialize <object>(ref reader, options);
                result = null;
                break;
            }

            return(result);
        }
Exemple #4
0
        public override ExplanationItem?Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            var typeDiscriminator = TypeElementConverterHelper.GetTypeDiscriminator(ref reader);

            ExplanationItem?result;

            switch (typeDiscriminator.ToLower())
            {
            case "relation":
            case "domain":
            case "entity":
            case "modifier":
            case "grammar":
            case "rhetoric":
            case "language":
            case "temporal":
                result = JsonSerializer.Deserialize <ExplanationIdItem>(ref reader, options);
                break;

            case "usage":
                result = JsonSerializer.Deserialize <ExplanationTextItem>(ref reader, options);
                break;

            case "article_ref":
                result = JsonSerializer.Deserialize <ExplanationArticleRefItem>(ref reader, options);
                break;

            default:
                // Read and throw away object so that the reader reaches EndObject token
                _      = JsonSerializer.Deserialize <object>(ref reader, options);
                result = null;
                break;
            }

            return(result);
        }