3#include <system/type_info.h>
4#include <system/span.h>
5#include <system/object_ext.h>
6#include <system/nullable.h>
7#include <system/details/pointer_collection_helpers.h>
8#include <system/details/patterns.h>
9#include <system/default.h>
10#include <system/constraints.h>
11#include <system/action.h>
14#include "system/text/json/serialization/json_resumable_converter_of_t.h"
15#include "system/text/json/writer/utf8_json_writer.h"
16#include "system/text/json/serialization/json_serializer_options.h"
17#include "system/text/json/serialization/write_stack.h"
18#include "system/text/json/serialization/converter_strategy.h"
19#include "system/text/json/serialization/json_converter.h"
20#include "system/text/json/reader/utf8_json_reader.h"
21#include "system/text/json/serialization/read_stack.h"
22#include "system/text/json/serialization/read_stack_frame.h"
23#include "system/text/json/json_token_type.h"
24#include "system/text/json/throw_helper.h"
25#include "system/text/json/json_helpers.h"
26#include "system/text/json/serialization/stack_frame_object_state.h"
27#include "system/text/json/serialization/json_serializer_helpers.h"
28#include "system/text/json/serialization/metadata_property_name.h"
29#include "system/text/json/serialization/polymorphic_serialization_state.h"
30#include "system/text/json/serialization/stack_frame_property_state.h"
31#include "system/text/json/serialization/metadata/polymorphic_type_resolver.h"
32#include "system/text/json/serialization/metadata/json_type_info.h"
33#include "system/text/json/serialization/write_stack_frame.h"
45class JsonPropertyInfoBase;
60template<
typename TDictionary>
66 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
67 RTTI_INFO_TEMPLATE_CLASS(
ThisType, ThisTypeBaseTypesInfo);
84 BaseType::SetTemplateWeakPtr(0);
105template<
typename TDictionary,
typename TKey,
typename TValue>
111 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
112 RTTI_INFO_TEMPLATE_CLASS(
ThisType, ThisTypeBaseTypesInfo);
120 return System::ObjectExt::GetType<TValue>();
125 return System::ObjectExt::GetType<TKey>();
130 ASPOSE_UNUSED(typeToConvert);
143 if (keyConverter->get_IsInternalConverter() && keyConverter->get_Type() == System::ObjectExt::GetType<String>())
145 key = System::ExplicitCast<TKey>(System::ExplicitCast<System::Object>(unescapedPropertyNameAsString));
149 key = keyConverter->ReadAsPropertyNameCore(
System::Ref(reader), keyConverter->get_Type(), options);
192 TValue element = _valueConverter->Read(
System::Ref(reader), get_ElementType(), options);
219 _valueConverter->TryRead(
System::Ref(reader), get_ElementType(), options,
System::Ref(state), element, System::Discard<bool>());
242 value = System::Default<TDictionary>();
255 bool success = polymorphicConverter->OnTryReadAsObject(
System::Ref(reader), polymorphicConverter->get_Type(), options,
System::Ref(state), objectResult);
256 value = System::ExplicitCast<TDictionary>(objectResult);
286 value = System::Default<TDictionary>();
329 value = System::Default<TDictionary>();
341 bool success = _valueConverter->TryRead(
System::Ref(reader), System::ObjectExt::GetType<TValue>(), options,
System::Ref(state), element2, System::Discard<bool>());
345 value = System::Default<TDictionary>();
357 jsonTypeInfo->InvokeOnDeserialized(result);
358 value = System::ExplicitCast<TDictionary>(result);
365 if (System::IsNull(dictionary))
367 writer->WriteNullValue();
377 jsonTypeInfo->InvokeOnSerializing(System::ExplicitCast<System::Object>(dictionary));
379 writer->WriteStartObject();
389 bool success = this->OnWriteResume(writer, dictionary, options,
System::Ref(state));
395 writer->WriteEndObject();
398 jsonTypeInfo->InvokeOnSerialized(System::ExplicitCast<System::Object>(dictionary));
409 BaseType::SetTemplateWeakPtr(0);
413 System::Details::CollectionHelpers::SetWeakPointer(0, _keyConverter);
417 System::Details::CollectionHelpers::SetWeakPointer(0, _valueConverter);
431 ASPOSE_UNUSED(state);
432 ASPOSE_UNUSED(options);
444 if (typeInfo->get_HasCreateObject() ==
false)
463 #ifdef ASPOSE_GET_SHARED_MEMBERS
464 void GetSharedMembers(System::Object::shared_members_type& result)
const override
468 result.Add(
"System::Text::Json::Serialization::JsonDictionaryConverter::_keyConverter", this->_keyConverter);
469 result.Add(
"System::Text::Json::Serialization::JsonDictionaryConverter::_valueConverter", this->_valueConverter);
static auto CoalesceAssign(T0 &value, T1 func) -> T0 &
Implementation of '??=' operator translation.
Definition: object_ext.h:748
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:126
static bool TryAdvanceWithOptionalReadAhead(Utf8JsonReader &reader, bool requiresReadAhead)
static void ReadWithVerify(Utf8JsonReader &reader)
static ReadOnlySpan< uint8_t > GetUnescapedSpan(Utf8JsonReader &reader)
System::Text::Json::PolymorphicSerializationState PolymorphicSerializationState
Definition: read_stack_frame.h:65
String JsonPropertyNameAsString
Definition: read_stack_frame.h:55
bool CanContainMetadata
Definition: read_stack_frame.h:62
Nullable< Serialization::JsonNumberHandling > NumberHandling
Definition: read_stack_frame.h:73
System::SharedPtr< System::Text::Json::Serialization::Metadata::JsonTypeInfoBase > get_BaseJsonTypeInfo()
System::SharedPtr< Object > ReturnValue
Definition: read_stack_frame.h:59
MetadataPropertyName MetadataPropertyNames
Definition: read_stack_frame.h:64
StackFramePropertyState PropertyState
Definition: read_stack_frame.h:52
StackFrameObjectState ObjectState
Definition: read_stack_frame.h:61
System::SharedPtr< Object > DictionaryKey
Definition: read_stack_frame.h:56
System::SharedPtr< System::Text::Json::Serialization::Metadata::JsonPropertyInfoBase > JsonPropertyInfo
Definition: read_stack_frame.h:51
System::SharedPtr< System::Text::Json::Serialization::Metadata::JsonTypeInfoBase > JsonTypeInfo
Definition: read_stack_frame.h:60
Definition: read_stack.h:35
bool SupportContinuation
Definition: read_stack.h:50
void ExitPolymorphicConverter(bool success)
ReadStackFrame Current
Definition: read_stack.h:44
System::SharedPtr< Serialization::Metadata::JsonPropertyInfoBase > get_ParentProperty()
TypeInfo PolymorphicResolvedType
Definition: read_stack.h:52
Definition: json_converter_of_t.h:80
Definition: json_dictionary_converter.h:107
virtual void ConvertCollection(ReadStack &state, System::SharedPtr< JsonSerializerOptions > options)
Definition: json_dictionary_converter.h:429
System::SharedPtr< JsonConverter< TKey > > _keyConverter
Definition: json_dictionary_converter.h:425
System::TypeInfo get_ElementType() override
Definition: json_dictionary_converter.h:118
static System::SharedPtr< JsonConverter< T > > GetConverter(System::SharedPtr< Metadata::JsonTypeInfoBase > typeInfo)
Definition: json_dictionary_converter.h:454
virtual ~JsonDictionaryConverter()
Definition: json_dictionary_converter.h:459
virtual void CreateCollection(Utf8JsonReader &reader, ReadStack &state)
Definition: json_dictionary_converter.h:435
void SetTemplateWeakPtr(uint32_t argument) override
Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containe...
Definition: json_dictionary_converter.h:404
bool OnTryRead(Utf8JsonReader &reader, const System::TypeInfo &typeToConvert, System::SharedPtr< JsonSerializerOptions > options, ReadStack &state, TDictionary &value) override
Definition: json_dictionary_converter.h:128
System::SharedPtr< JsonConverter< TValue > > _valueConverter
Definition: json_dictionary_converter.h:426
bool OnTryWrite(System::SharedPtr< Utf8JsonWriter > writer, TDictionary dictionary, System::SharedPtr< JsonSerializerOptions > options, WriteStack &state) override
Definition: json_dictionary_converter.h:363
virtual void Add(TKey key, const TValue &value, System::SharedPtr< JsonSerializerOptions > options, ReadStack &state)=0
System::TypeInfo get_KeyType() override
Definition: json_dictionary_converter.h:123
friend class JsonDictionaryConverter
Definition: json_dictionary_converter.h:114
Definition: json_dictionary_converter.h:62
bool get_SupportsCreateObjectDelegate() override
Definition: json_dictionary_converter.h:73
virtual ~JsonDictionaryConverter()
Definition: json_dictionary_converter.h:92
virtual bool OnWriteResume(System::SharedPtr< Utf8JsonWriter > writer, TDictionary dictionary, System::SharedPtr< JsonSerializerOptions > options, WriteStack &state)=0
void SetTemplateWeakPtr(uint32_t argument) override
Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containe...
Definition: json_dictionary_converter.h:79
friend class JsonDictionaryConverter
Definition: json_dictionary_converter.h:69
Definition: json_converter.h:45
Definition: json_resumable_converter_of_t.h:42
Definition: json_type_info_of_t.h:84
static void ThrowJsonException_DeserializeUnableToConvertValue(const TypeInfo &propertyType)
static void ThrowNotSupportedException_DeserializeNoConstructor(System::SharedPtr< Serialization::Metadata::JsonTypeInfoBase > typeInfo, Utf8JsonReader &reader, ReadStack &state)
static void ThrowUnexpectedMetadataException(ReadOnlySpan< uint8_t > propertyName, Utf8JsonReader &reader, ReadStack &state)
Definition: utf8_json_reader.h:78
JsonTokenType get_TokenType()
bool ProcessedStartToken
Definition: write_stack_frame.h:58
System::SharedPtr< System::Text::Json::Serialization::Metadata::JsonPropertyInfoBase > JsonPropertyInfo
Definition: write_stack_frame.h:54
bool ProcessedEndToken
Definition: write_stack_frame.h:59
System::SharedPtr< System::Text::Json::Serialization::Metadata::JsonTypeInfoBase > JsonTypeInfo
Definition: write_stack_frame.h:56
Definition: write_stack.h:34
WriteStackFrame Current
Definition: write_stack.h:45
bool get_CurrentContainsMetadata()
Represents a particular type and provides information about it.
Definition: type_info.h:109
@ Text
Defines color adjustment information for text.
void ValidateMetadataForObjectConverter(ReadStack &state)
MetadataPropertyName WriteMetadataForObject(System::SharedPtr< JsonConverterBase > jsonConverter, WriteStack &state, System::SharedPtr< Utf8JsonWriter > writer)
bool IsMetadataPropertyName(ReadOnlySpan< uint8_t > propertyName, System::SharedPtr< Metadata::PolymorphicTypeResolver > resolver)
bool TryReadMetadata(System::SharedPtr< JsonConverterBase > converter, System::SharedPtr< Metadata::JsonTypeInfoBase > jsonTypeInfo, Utf8JsonReader &reader, ReadStack &state)
@ PolymorphicReEntryStarted
MetadataPropertyName
Definition: metadata_property_name.h:13
ConverterStrategy
Definition: converter_strategy.h:13
Definition: db_command.h:9
SmartPtr< X > MakeSharedPtr(X *p)
Converts raw pointer to smart pointer.
Definition: smart_ptr.h:1640
decltype(Ref(std::declval< T & >())) Ref(const std::reference_wrapper< T > &wrapper)
Wrapper to make sure Ref(std::ref(DynamicWeakPtr)) works.
Definition: dynamic_weak_ptr.h:207
static auto SafeInvoke(T0 &&expr, T1 &&func)
Implementation of '?.' operator translation.
Definition: object_ext.h:1434
std::enable_if_t< Details::CastType< Source, Result >::None, Result > ExplicitCast(const Source &value)
Casts the source type to the result type using explicit cast. Used when the source and the result typ...
Definition: object_ext.h:960