CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
json_metadata_services.h
1#pragma once
2
3#include <system/version.h>
4#include <system/value_tuple.h>
5#include <system/uri.h>
6#include <system/type_info.h>
7#include <system/timespan.h>
8#include <system/reflection/member_types.h>
9#include <system/object_ext.h>
10#include <system/nullable.h>
11#include <system/guid.h>
12#include <system/func.h>
13#include <system/exceptions.h>
14#include <system/details/patterns.h>
15#include <system/decimal.h>
16#include <system/date_time_offset.h>
17#include <system/date_time.h>
18#include <system/constraints.h>
19#include <system/collections/stack.h>
20#include <system/collections/queue.h>
21#include <system/collections/list.h>
22#include <system/collections/iset.h>
23#include <system/collections/ilist_ng.h>
24#include <system/collections/ilist.h>
25#include <system/collections/ienumerator.h>
26#include <system/collections/ienumerable_ng.h>
27#include <system/collections/ienumerable.h>
28#include <system/collections/idictionary.h>
29#include <system/collections/icollection.h>
30#include <system/collections/dictionary.h>
31#include <system/array.h>
32#include <system/action.h>
33#include <cstdint>
34#include <functional>
35
36#include "system/text/json/serialization/json_converter.h"
37#include "system/text/json/serialization/converters/value/enum_converter.h"
38#include "system/text/json/serialization/converters/casting_converter.h"
39#include "system/text/json/nodes/json_array.h"
40#include "system/text/json/document/json_element.h"
41#include "system/text/json/nodes/json_node.h"
42#include "system/text/json/nodes/json_object.h"
43#include "system/text/json/document/json_document.h"
44#include "system/text/json/serialization/json_serializer_options.h"
45#include "system/text/json/serialization/metadata/json_collection_info_values_of_t_collection.h"
46#include "system/text/json/serialization/converters/collection/array_converter.h"
47#include "system/text/json/serialization/converters/collection/list_of_t_converter.h"
48#include "system/text/json/serialization/converters/collection/dictionary_of_t_key_t_value_converter.h"
49#include "system/text/json/serialization/converters/collection/i_dictionary_of_t_key_t_value_converter.h"
50#include "system/text/json/serialization/converters/collection/i_list_converter.h"
51#include "system/text/json/serialization/converters/collection/i_list_of_t_converter.h"
52#include "system/text/json/serialization/converters/collection/i_set_of_t_converter.h"
53#include "system/text/json/serialization/converters/collection/i_collection_of_t_converter.h"
54#include "system/text/json/serialization/converters/collection/stack_of_t_converter.h"
55#include "system/text/json/serialization/converters/collection/queue_of_t_converter.h"
56#include "system/text/json/serialization/converters/collection/i_enumerable_of_t_converter.h"
57#include "system/text/json/serialization/converters/collection/i_dictionary_converter.h"
58#include "system/text/json/serialization/converters/collection/i_enumerable_converter.h"
59#include "system/text/json/serialization/converters/value/unsupported_type_converter.h"
60#include "system/text/json/serialization/converters/value/nullable_converter.h"
61#include "system/text/json/serialization/metadata/json_property_info_values_of_t.h"
62#include "system/text/json/serialization/metadata/json_type_info.h"
63#include "system/text/json/serialization/metadata/json_object_info_values_of_t.h"
64#include "system/text/json/serialization/json_type_classifier.h"
65#include "system/text/json/serialization/json_serializer_context.h"
66#include "system/text/json/serialization/converters/collection/stack_or_queue_converter.h"
67#include "system/text/json/writer/utf8_json_writer.h"
68#include "system/text/json/serialization/json_number_handling.h"
69#include "system/text/json/serialization/metadata/json_polymorphism_options.h"
70#include "system/text/json/serialization/json_type_classifier_factory.h"
71#include "system/text/json/serialization/converters/json_metadata_services_converter.h"
72#include "system/text/json/serialization/converters/object/object_default_converter.h"
73#include "system/text/json/serialization/converters/object/object_with_parameterized_constructor_converter_large.h"
74#include "system/text/json/serialization/json_ignore_condition.h"
75#include "system/text/json/serialization/i_json_on_serializing.h"
76#include "system/text/json/serialization/i_json_on_serialized.h"
77#include "system/text/json/serialization/i_json_on_deserializing.h"
78#include "system/text/json/serialization/i_json_on_deserialized.h"
79#include "system/text/json/serialization/metadata/json_type_info_kind.h"
80
81namespace System
82{
83namespace Collections
84{
85namespace Generic
86{
87template <typename, typename> class KeyValuePair;
88} // namespace Generic
89} // namespace Collections
90namespace Text
91{
92namespace Json
93{
94namespace Serialization
95{
96template <typename> class JsonConverter;
97namespace Metadata
98{
99class JsonParameterInfoValues;
100} // namespace Metadata
101} // namespace Serialization
102class Utf8JsonReader;
103} // namespace Json
104} // namespace Text
105} // namespace System
106
107namespace System {
108
109namespace Text {
110
111namespace Json {
112
113namespace Serialization {
114
115namespace Metadata {
116
118{
120
121 friend class JsonTypeInfoBase;
122public:
123
154
155 template<typename TElement>
157 {
158 return CreateCore<System::SharedPtr<Array<TElement>>>(options, collectionInfo, System::MakeObject<Converters::ArrayConverter<System::SharedPtr<Array<TElement>>, TElement>>());
159 }
160
161 template<typename TCollection, typename TElement>
163 {
164 typedef Collections::Generic::List<TElement> BaseT_List;
165 assert_is_base_of(BaseT_List, TCollection);
166
167 return CreateCore<TCollection>(options, collectionInfo, System::MakeObject<Converters::ListOfTConverter<TCollection, TElement>>());
168 }
169
170 template<typename TCollection, typename TKey, typename TValue>
172 {
173 typedef Collections::Generic::Dictionary<TKey, TValue> BaseT_Dictionary;
174 assert_is_base_of(BaseT_Dictionary, TCollection);
175
176 return CreateCore<TCollection>(options, collectionInfo, System::MakeObject<Converters::DictionaryOfTKeyTValueConverter<TCollection, TKey, TValue>>());
177 }
178
179 template<typename TCollection, typename TKey, typename TValue>
181 {
182 typedef Collections::Generic::IDictionary<TKey, TValue> BaseT_IDictionary;
183 assert_is_base_of(BaseT_IDictionary, TCollection);
184
185 return CreateCore<TCollection>(options, collectionInfo, System::MakeObject<Converters::IDictionaryOfTKeyTValueConverter<TCollection, TKey, TValue>>());
186 }
187
188 template<typename TCollection>
190 {
191 typedef Collections::IList BaseT_IList;
192 assert_is_base_of(BaseT_IList, TCollection);
193
194 return CreateCore<TCollection>(options, collectionInfo, System::MakeObject<Converters::IListConverter<TCollection>>());
195 }
196
197 template<typename TCollection, typename TElement>
199 {
200 typedef Collections::Generic::IList<TElement> BaseT_IList;
201 assert_is_base_of(BaseT_IList, TCollection);
202
203 return CreateCore<TCollection>(options, collectionInfo, System::MakeObject<Converters::IListOfTConverter<TCollection, TElement>>());
204 }
205
206 template<typename TCollection, typename TElement>
208 {
209 typedef Collections::Generic::ISet<TElement> BaseT_ISet;
210 assert_is_base_of(BaseT_ISet, TCollection);
211
212 return CreateCore<TCollection>(options, collectionInfo, System::MakeObject<Converters::ISetOfTConverter<TCollection, TElement>>());
213 }
214
215 template<typename TCollection, typename TElement>
217 {
218 typedef Collections::Generic::ICollection<TElement> BaseT_ICollection;
219 assert_is_base_of(BaseT_ICollection, TCollection);
220
221 return CreateCore<TCollection>(options, collectionInfo, System::MakeObject<Converters::ICollectionOfTConverter<TCollection, TElement>>());
222 }
223
224 template<typename TCollection, typename TElement>
226 {
227 typedef Collections::Generic::Stack<TElement> BaseT_Stack;
228 assert_is_base_of(BaseT_Stack, TCollection);
229
230 return CreateCore<TCollection>(options, collectionInfo, System::MakeObject<Converters::StackOfTConverter<TCollection, TElement>>());
231 }
232
233 template<typename TCollection, typename TElement>
235 {
236 typedef Collections::Generic::Queue<TElement> BaseT_Queue;
237 assert_is_base_of(BaseT_Queue, TCollection);
238
239 return CreateCore<TCollection>(options, collectionInfo, System::MakeObject<Converters::QueueOfTConverter<TCollection, TElement>>());
240 }
241
242 template<typename TCollection, typename TElement>
244 {
245 typedef Collections::Generic::IEnumerable<TElement> BaseT_IEnumerable;
246 assert_is_base_of(BaseT_IEnumerable, TCollection);
247
248 return CreateCore<TCollection>(options, collectionInfo, System::MakeObject<Converters::IEnumerableOfTConverter<TCollection, TElement>>());
249 }
250
251 template<typename TCollection>
253 {
255 assert_is_base_of(BaseT_IDictionary, TCollection);
256
257 return CreateCore<TCollection>(options, collectionInfo, System::MakeObject<Converters::IDictionaryConverter<TCollection>>());
258 }
259
260 template<typename TCollection>
262 {
263 typedef Collections::IEnumerable BaseT_IEnumerable;
264 assert_is_base_of(BaseT_IEnumerable, TCollection);
265
266 return CreateStackOrQueueInfo<TCollection>(options, collectionInfo, addFunc);
267 }
268
269 template<typename TCollection>
271 {
272 typedef Collections::IEnumerable BaseT_IEnumerable;
273 assert_is_base_of(BaseT_IEnumerable, TCollection);
274
275 return CreateStackOrQueueInfo<TCollection>(options, collectionInfo, addFunc);
276 }
277
278 template<typename TCollection>
280 {
281 typedef Collections::IEnumerable BaseT_IEnumerable;
282 assert_is_base_of(BaseT_IEnumerable, TCollection);
283
284 return CreateCore<TCollection>(options, collectionInfo, System::MakeObject<Converters::IEnumerableConverter<TCollection>>());
285 }
286
287 template<typename T>
289 {
290 return System::MakeObject<Converters::UnsupportedTypeConverter<T>>();
291 }
292
293 template<typename T>
295 {
296 return System::MakeObject<Converters::EnumConverter<T>>(Converters::EnumConverterOptions::AllowNumbers, nullptr, options);
297 }
298
299 template<typename T>
300 static typename std::enable_if<!System::Constraints::IsCsPointer<T>::value, System::SharedPtr<JsonConverter<Nullable<T>>>>::type
302 {
303 assert_is_cs_struct(T);
304
305 if (System::IsNull(underlyingTypeInfo))
306 {
307 throw System::ArgumentNullException(u"underlyingTypeInfo");
308 }
309
310 System::SharedPtr<JsonConverter<T>> underlyingConverter = GetTypedConverter<T>(underlyingTypeInfo->get_Converter());
311
312 return System::MakeObject<Converters::NullableConverter<T>>(underlyingConverter);
313 }
314
315 template<typename T>
316 static typename std::enable_if<System::Constraints::IsCsPointer<T>::value, System::SharedPtr<JsonConverter<Nullable<T>>>>::type
318 {
319 if (System::IsNull(underlyingTypeInfo))
320 {
321 throw System::ArgumentNullException(u"underlyingTypeInfo");
322 }
323
324 return System::MakeObject<Converters::CastingConverter<Nullable<T>>>(underlyingTypeInfo->get_Converter());
325 }
326
327 template<typename T>
328 static typename std::enable_if<!System::Constraints::IsCsPointer<T>::value, System::SharedPtr<JsonConverter<Nullable<T>>>>::type
330 {
331 assert_is_cs_struct(T);
332
333 if (System::IsNull(options))
334 {
335 throw System::ArgumentNullException(u"options");
336 }
337
338 System::SharedPtr<JsonConverter<T>> underlyingConverter = GetTypedConverter<T>(options->GetConverterInternal(System::ObjectExt::GetType<T>()));
339
340 return System::MakeObject<Converters::NullableConverter<T>>(underlyingConverter);
341 }
342
343 template<typename T>
344 static typename std::enable_if<System::Constraints::IsCsPointer<T>::value, System::SharedPtr<JsonConverter<Nullable<T>>>>::type
346 {
347 if (System::IsNull(options))
348 {
349 throw System::ArgumentNullException(u"options");
350 }
351
352 return System::MakeObject<Converters::CastingConverter<Nullable<T>>>(options->GetTypeInfo(System::ObjectExt::GetType<T>())->get_Converter());
353 }
354
355 template<typename T>
357 {
358 if (System::IsNull(options))
359 {
360 throw System::ArgumentNullException(u"options");
361 }
362 if (System::IsNull(propertyInfo))
363 {
364 throw System::ArgumentNullException(u"propertyInfo");
365 }
366
367 TypeInfo declaringType = propertyInfo->get_DeclaringType();
368 if (declaringType == nullptr)
369 {
370 throw ArgumentException(u"DeclaringType");
371 }
372
373 String propertyName = propertyInfo->get_PropertyName();
374 if (propertyName == nullptr)
375 {
376 throw ArgumentException(u"PropertyName");
377 }
378
379 if (!propertyInfo->get_IsProperty() && propertyInfo->get_IsVirtual())
380 {
381 throw InvalidOperationException(System::String::Format(u"A 'field' member cannot be 'virtual'. See arguments for the '{0}' and '{1}' parameters. ", System::String(u"IsProperty"), System::String(u"IsVirtual")));
382 }
383
384 return CreatePropertyInfoCore<T>(propertyInfo, options);
385 }
386
387 template<typename T>
389 {
390 if (System::IsNull(options))
391 {
392 throw System::ArgumentNullException(u"options");
393 }
394 if (System::IsNull(objectInfo))
395 {
396 throw System::ArgumentNullException(u"objectInfo");
397 }
398
399 return CreateCore<T>(options, objectInfo);
400 }
401
402 template<typename T>
404 {
405 if (System::IsNull(options))
406 {
407 throw System::ArgumentNullException(u"options");
408 }
409 if (System::IsNull(converter))
410 {
411 throw System::ArgumentNullException(u"converter");
412 }
413
414 System::SharedPtr<JsonTypeInfo<T>> info = CreateCore<T>(converter, options);
415 return info;
416 }
417
418protected:
419
420 template<typename T>
422 {
423 System::SharedPtr<JsonConverter<T>> typedConverter = System::AsCast<System::Text::Json::Serialization::JsonConverter<T>>(converter);
424 if (System::IsNull(typedConverter))
425 {
426 throw InvalidOperationException(System::String::Format(u"The converter '{0}' is not compatible with the type '{1}'.", typedConverter, System::ExplicitCast<System::Object>(System::ObjectExt::GetType<T>())));
427 }
428
429 return typedConverter;
430 }
431
434
435private:
436
437 static System::SharedPtr<JsonConverter<bool>> _booleanConverter;
439 static System::SharedPtr<JsonConverter<uint8_t>> _byteConverter;
440 static System::SharedPtr<JsonConverter<char16_t>> _charConverter;
441 static System::SharedPtr<JsonConverter<DateTime>> _dateTimeConverter;
442 static System::SharedPtr<JsonConverter<DateTimeOffset>> _dateTimeOffsetConverter;
443 static System::SharedPtr<JsonConverter<Decimal>> _decimalConverter;
444 static System::SharedPtr<JsonConverter<double>> _doubleConverter;
445 static System::SharedPtr<JsonConverter<Guid>> _guidConverter;
446 static System::SharedPtr<JsonConverter<int16_t>> _int16Converter;
447 static System::SharedPtr<JsonConverter<int32_t>> _int32Converter;
448 static System::SharedPtr<JsonConverter<int64_t>> _int64Converter;
450 static System::SharedPtr<JsonConverter<JsonElement>> _jsonElementConverter;
455 static System::SharedPtr<JsonConverter<Memory<uint8_t>>> _memoryByteConverter;
456 static System::SharedPtr<JsonConverter<ReadOnlyMemory<uint8_t>>> _readOnlyMemoryByteConverter;
458 static System::SharedPtr<JsonConverter<float>> _singleConverter;
459 static System::SharedPtr<JsonConverter<int8_t>> _sByteConverter;
460 static System::SharedPtr<JsonConverter<String>> _stringConverter;
461 static System::SharedPtr<JsonConverter<TimeSpan>> _timeSpanConverter;
462 static System::SharedPtr<JsonConverter<uint16_t>> _uInt16Converter;
463 static System::SharedPtr<JsonConverter<uint32_t>> _uInt32Converter;
464 static System::SharedPtr<JsonConverter<uint64_t>> _uInt64Converter;
466 static System::SharedPtr<JsonConverter<Version>> _versionConverter;
467
468 template<typename TCollection>
470 {
471 typedef Collections::IEnumerable BaseT_IEnumerable;
472 assert_is_base_of(BaseT_IEnumerable, TCollection);
473
474 if (System::Is(System::ExplicitCast<System::Object>(addFunc), nullptr))
475 {
476 throw System::ArgumentNullException(u"addFunc");
477 }
478
479 return CreateCore<TCollection>(options, collectionInfo, System::MakeObject<Converters::StackOrQueueConverter<TCollection>>(), nullptr, System::ExplicitCast<System::Object>(addFunc));
480 }
481
487 template<typename T>
488 static void SetInterfaceCallbacks(System::SharedPtr<JsonTypeInfo<T>> typeInfo)
489 {
490 JsonTypeInfoKind kind = typeInfo->get_Kind();
492 {
493 return;
494 }
495
497 {
498 typeInfo->set_FastOnSerializing([](System::SharedPtr<Object> obj)
499 {
500 (System::ExplicitCast<System::Text::Json::Serialization::IJsonOnSerializing>(obj))->OnSerializing();
501 });
502 }
503
505 {
506 typeInfo->set_FastOnSerialized([](System::SharedPtr<Object> obj)
507 {
508 (System::ExplicitCast<System::Text::Json::Serialization::IJsonOnSerialized>(obj))->OnSerialized();
509 });
510 }
511
513 {
514 typeInfo->set_FastOnDeserializing([](System::SharedPtr<Object> obj)
515 {
516 (System::ExplicitCast<System::Text::Json::Serialization::IJsonOnDeserializing>(obj))->OnDeserializing();
517 });
518 }
519
521 {
522 typeInfo->set_FastOnDeserialized([](System::SharedPtr<Object> obj)
523 {
524 (System::ExplicitCast<System::Text::Json::Serialization::IJsonOnDeserialized>(obj))->OnDeserialized();
525 });
526 }
527 }
528
529 template<typename T>
531 {
532 auto typeInfo = JsonTypeInfo<T>::MakeObject(converter, options);
533 PopulatePolymorphismMetadata(typeInfo, nullptr, nullptr);
534 typeInfo->MapInterfaceTypesToCallbacks();
535 SetInterfaceCallbacks(typeInfo);
536
537 // Plug in any converter configuration -- should be run last.
538 converter->ConfigureJsonTypeInfo(typeInfo, options);
539 typeInfo->set_IsCustomized(false);
540 return typeInfo;
541 }
542
543 template<typename T>
544 static System::SharedPtr<JsonTypeInfo<T>> CreateCore(System::SharedPtr<JsonSerializerOptions> options, System::SharedPtr<JsonObjectInfoValues<T>> objectInfo)
545 {
546 System::SharedPtr<JsonConverter<T>> converter = GetConverter<T>(objectInfo);
547 auto typeInfo = JsonTypeInfo<T>::MakeObject(converter, options);
548 if (System::Is(objectInfo->get_ObjectWithParameterizedConstructorCreator(), !(_== nullptr)))
549 {
550 // NB parameter metadata must be populated *before* property metadata
551 // so that properties can be linked to their associated parameters.
552 typeInfo->set_CreateObjectWithArgs(System::ExplicitCast<System::Object>(objectInfo->get_ObjectWithParameterizedConstructorCreator()));
553 PopulateParameterInfoValues(typeInfo, objectInfo->get_ConstructorParameterMetadataInitializer());
554 }
555 else
556 {
557 if (objectInfo->get_FastObjectCreator() != nullptr)
558 {
559 typeInfo->set_FastCreateObject(objectInfo->get_FastObjectCreator());
560 }
561 else
562 {
563 typeInfo->SetCreateObjectIfCompatible(objectInfo->get_ObjectCreator());
564 }
565
566 if (objectInfo->get_FastObjectCreator() == nullptr)
567 {
568 typeInfo->set_CreateObjectForExtensionDataProperty((System::ExplicitCast<System::Text::Json::Serialization::Metadata::JsonTypeInfoBase>(typeInfo))->get_CreateObject());
569 }
570 }
571
572 if (objectInfo->get_FastPropertyMetadataInitializer() != nullptr)
573 {
574 typeInfo->set_FastSourceGenDelayedPropertyInitializer(objectInfo->get_FastPropertyMetadataInitializer());
575 }
576 else if (System::Is(objectInfo->get_PropertyMetadataInitializer(), !(_== nullptr)))
577 {
578 typeInfo->set_SourceGenDelayedPropertyInitializer(objectInfo->get_PropertyMetadataInitializer());
579 }
580 else
581 {
582 typeInfo->set_PropertyMetadataSerializationNotSupported(true);
583 }
584
585 typeInfo->set_SerializeHandler(objectInfo->get_SerializeHandler());
586 typeInfo->set_FastSerializeHandler(objectInfo->get_FastSerializeHandler(), objectInfo->get_FastSerializeContext());
587 typeInfo->set_NumberHandling(objectInfo->get_NumberHandling());
588
589 PopulatePolymorphismMetadata(typeInfo, objectInfo->get_PolymorphismOptions(), objectInfo->get_TypeClassifierFactory());
590
591 typeInfo->MapInterfaceTypesToCallbacks();
592 SetInterfaceCallbacks(typeInfo);
593
594 // Plug in any converter configuration -- should be run last.
595 converter->ConfigureJsonTypeInfo(typeInfo, options);
596 typeInfo->set_IsCustomized(false);
597 return typeInfo;
598 }
599
600 template<typename T>
601 static System::SharedPtr<JsonTypeInfo<T>> CreateCore(System::SharedPtr<JsonSerializerOptions> options, System::SharedPtr<JsonCollectionInfoValues<T>> collectionInfo, System::SharedPtr<JsonConverter<T>> converter, System::SharedPtr<Object> createObjectWithArgs = nullptr, System::SharedPtr<Object> addFunc = nullptr)
602 {
603 if (System::IsNull(collectionInfo))
604 {
605 throw System::ArgumentNullException(u"collectionInfo");
606 }
607
608 converter = (System::Is(collectionInfo->get_SerializeHandler(), !(_== nullptr)) || collectionInfo->get_FastSerializeHandler() != nullptr) ? System::MakeObject<Converters::JsonMetadataServicesConverter<T>>(converter) : converter;
609
610 System::SharedPtr<JsonTypeInfo<T>> typeInfo = JsonTypeInfo<T>::MakeObject(converter, options);
611
612 typeInfo->set_KeyTypeInfo(collectionInfo->get_KeyInfo());
613 typeInfo->set_ElementTypeInfo(collectionInfo->get_ElementInfo());
614
615 typeInfo->set_NumberHandling(collectionInfo->get_NumberHandling());
616 typeInfo->set_SerializeHandler(collectionInfo->get_SerializeHandler());
617 typeInfo->set_FastSerializeHandler(collectionInfo->get_FastSerializeHandler(), collectionInfo->get_FastSerializeContext());
618 typeInfo->set_CreateObjectWithArgs(createObjectWithArgs);
619 typeInfo->set_AddMethodDelegate(addFunc);
620 if (collectionInfo->get_FastObjectCreator() != nullptr)
621 {
622 typeInfo->set_FastCreateObject(collectionInfo->get_FastObjectCreator());
623 }
624 else
625 {
626 typeInfo->SetCreateObjectIfCompatible(collectionInfo->get_ObjectCreator());
627 }
628 PopulatePolymorphismMetadata(typeInfo, collectionInfo->get_PolymorphismOptions(), collectionInfo->get_TypeClassifierFactory());
629
630 typeInfo->MapInterfaceTypesToCallbacks();
631 SetInterfaceCallbacks(typeInfo);
632
633 // Plug in any converter configuration -- should be run last.
634 converter->ConfigureJsonTypeInfo(typeInfo, options);
635 typeInfo->set_IsCustomized(false);
636 return typeInfo;
637 }
638
639 template<typename T>
640 static System::SharedPtr<JsonConverter<T>> GetConverter(System::SharedPtr<JsonObjectInfoValues<T>> objectInfo)
641 {
642
643 System::SharedPtr<JsonConverter<T>> converter = (!System::IsNull(objectInfo->get_ObjectWithParameterizedConstructorCreator())) ? System::MakeObject<Converters::LargeObjectWithParameterizedConstructorConverter<T>>() : System::MakeObject<Converters::ObjectDefaultConverter<T>>();
644
645 return (!System::IsNull(objectInfo->get_SerializeHandler()) || objectInfo->get_FastSerializeHandler() != nullptr) ? System::MakeObject<Converters::JsonMetadataServicesConverter<T>>(converter) : converter;
646 }
647
648 static ASPOSECPP_SHARED_API void PopulatePolymorphismMetadata(
652 static ASPOSECPP_SHARED_API void PopulateParameterInfoValues(System::SharedPtr<JsonTypeInfoBase> typeInfo, Func<System::SharedPtr<Array<System::SharedPtr<JsonParameterInfoValues>>>> paramFactory);
653 template<typename T>
654 static System::SharedPtr<JsonPropertyInfo<T>> CreatePropertyInfoCore(System::SharedPtr<JsonPropertyInfoValues<T>> propertyInfoValues, System::SharedPtr<JsonSerializerOptions> options)
655 {
656 auto propertyInfo = System::MakeObject<JsonPropertyInfo<T>>(propertyInfoValues->get_DeclaringType(), nullptr, options);
657
658 DeterminePropertyName(propertyInfo, propertyInfoValues->get_PropertyName(), propertyInfoValues->get_JsonPropertyName());
659
660 propertyInfo->set_MemberName(propertyInfoValues->get_PropertyName());
661 propertyInfo->set_MemberType(propertyInfoValues->get_IsProperty() ? System::Reflection::MemberTypes::Property : System::Reflection::MemberTypes::Field);
662 propertyInfo->set_SrcGen_IsPublic(propertyInfoValues->get_IsPublic());
663 propertyInfo->set_SrcGen_HasJsonInclude(propertyInfoValues->get_HasJsonInclude());
664 propertyInfo->set_IsExtensionData(propertyInfoValues->get_IsExtensionData());
665 propertyInfo->set_CustomConverter(propertyInfoValues->get_Converter());
666
667 if (propertyInfo->get_IgnoreCondition() != System::Text::Json::Serialization::JsonIgnoreCondition::Always)
668 {
669 if (propertyInfoValues->get_FastGetter() != nullptr)
670 {
671 propertyInfo->set_GetFast(propertyInfoValues->get_FastGetter());
672 }
673 else
674 {
675 propertyInfo->set_Get(propertyInfoValues->get_Getter());
676 }
677
678 if (propertyInfoValues->get_FastSetter() != nullptr)
679 {
680 propertyInfo->set_SetFast(propertyInfoValues->get_FastSetter());
681 }
682 else
683 {
684 propertyInfo->set_Set(propertyInfoValues->get_Setter());
685 }
686 }
687
688 propertyInfo->set_IgnoreCondition(propertyInfoValues->get_IgnoreCondition());
689 propertyInfo->set_JsonTypeInfo(propertyInfoValues->get_PropertyTypeInfo());
690 propertyInfo->set_NumberHandling(propertyInfoValues->get_NumberHandling());
691
692 return propertyInfo;
693 }
694
695 static ASPOSECPP_SHARED_API void DeterminePropertyName(System::SharedPtr<JsonPropertyInfoBase> propertyInfo, String declaredPropertyName, String declaredJsonPropertyName);
696
697public:
699};
700
701} // namespace Metadata
702} // namespace Serialization
703} // namespace Json
704} // namespace Text
705} // namespace System
Class that represents an array data structure. Objects of this class should only be allocated using S...
Definition: array.h:296
Forward declaration of Dictionary class.
Definition: dictionary.h:96
Interface of collection of elements. Objects of this class should only be allocated using System::Mak...
Definition: icollection.h:20
Interface for dictionary-alike containers. Objects of this class should only be allocated using Syste...
Definition: idictionary.h:21
Interface of object providing enumerator on contained elements.
Definition: ienumerable.h:26
Interface of indexed container of elements. Objects of this class should only be allocated using Syst...
Definition: ilist.h:20
Interface of collection containing a set of unique elements. Objects of this class should only be all...
Definition: iset.h:18
List forward declaration.
Definition: list.h:129
Queue class forward declaration.
Definition: queue.h:88
Stack class forward declaration.
Definition: stack.h:87
IEnumerable is the base interface for all non-generic collections that can be enumerated.
Definition: ienumerable_ng.h:10
IList Represents a non-generic collection of objects that can be individually accessed by index.
Definition: ilist_ng.h:9
Template that represents wrapper of exceptions that are derived from Exception class.
Definition: exception.h:118
Function delegate. This type should be allocated on stack and passed to functions by value or by refe...
Definition: func.h:82
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 String Format(const SharedPtr< IFormatProvider > &fp, const String &format, const Args &... args)
Formats string in C# style.
Definition: string.h:1449
Definition: dictionary_of_t_key_t_value_converter.h:36
Definition: i_dictionary_of_t_key_t_value_converter.h:34
Definition: json_collection_info_values_of_t_collection.h:43
static System::SharedPtr< JsonConverter< uint8_t > > get_ByteConverter()
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateStackInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo)
Definition: json_metadata_services.h:225
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateIListInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo)
Definition: json_metadata_services.h:189
static System::SharedPtr< JsonPropertyInfoBase > CreatePropertyInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonPropertyInfoValues< T > > propertyInfo)
Definition: json_metadata_services.h:356
static System::SharedPtr< JsonConverter< String > > get_StringConverter()
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateIEnumerableInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo)
Definition: json_metadata_services.h:279
static System::SharedPtr< JsonConverter< TimeSpan > > get_TimeSpanConverter()
static System::SharedPtr< JsonTypeInfo< System::SharedPtr< Array< TElement > > > > CreateArrayInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< System::SharedPtr< Array< TElement > > > > collectionInfo)
Definition: json_metadata_services.h:156
static System::SharedPtr< JsonConverter< T > > GetEnumConverter(System::SharedPtr< JsonSerializerOptions > options)
Definition: json_metadata_services.h:294
static System::SharedPtr< JsonConverter< Version > > get_VersionConverter()
static System::SharedPtr< JsonConverter< System::SharedPtr< Nodes::JsonArray > > > get_JsonArrayConverter()
static System::SharedPtr< JsonConverter< DateTime > > get_DateTimeConverter()
static System::SharedPtr< JsonConverter< ReadOnlyMemory< uint8_t > > > get_ReadOnlyMemoryByteConverter()
static System::SharedPtr< JsonTypeInfo< T > > CreateObjectInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonObjectInfoValues< T > > objectInfo)
Definition: json_metadata_services.h:388
static System::SharedPtr< JsonConverter< uint64_t > > get_UInt64Converter()
static System::SharedPtr< JsonTypeInfo< T > > CreateValueInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonConverterBase > converter)
Definition: json_metadata_services.h:403
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateQueueInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo)
Definition: json_metadata_services.h:234
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateICollectionInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo)
Definition: json_metadata_services.h:216
static System::SharedPtr< JsonConverter< T > > GetTypedConverter(System::SharedPtr< JsonConverterBase > converter)
Definition: json_metadata_services.h:421
static System::SharedPtr< JsonConverter< System::SharedPtr< JsonDocument > > > get_JsonDocumentConverter()
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateQueueInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo, Action< TCollection, System::SharedPtr< Object > > addFunc)
Definition: json_metadata_services.h:270
static System::SharedPtr< JsonConverter< DateTimeOffset > > get_DateTimeOffsetConverter()
static void PopulateProperties(System::SharedPtr< JsonTypeInfoBase > typeInfo, System::SharedPtr< JsonTypeInfoBase::JsonPropertyInfoList > propertyList, Func< System::SharedPtr< JsonSerializerContext >, System::SharedPtr< Array< System::SharedPtr< JsonPropertyInfoBase > > > > propInitFunc)
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateDictionaryInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo)
Definition: json_metadata_services.h:171
static void PopulateProperties(System::SharedPtr< JsonTypeInfoBase > typeInfo, System::SharedPtr< JsonTypeInfoBase::JsonPropertyInfoList > propertyList, JsonTypeInfoBase::PropertyMetadataInitializerFn propInitFunc, System::SharedPtr< JsonSerializerOptions > options)
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateIListInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo)
Definition: json_metadata_services.h:198
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateIDictionaryInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo)
Definition: json_metadata_services.h:252
static System::SharedPtr< JsonConverter< Decimal > > get_DecimalConverter()
static System::SharedPtr< JsonConverter< char16_t > > get_CharConverter()
static System::SharedPtr< JsonConverter< System::SharedPtr< Nodes::JsonValueBase > > > get_JsonValueConverter()
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateIDictionaryInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo)
Definition: json_metadata_services.h:180
static System::SharedPtr< JsonConverter< float > > get_SingleConverter()
static System::SharedPtr< JsonConverter< System::SharedPtr< Nodes::JsonNode > > > get_JsonNodeConverter()
static System::SharedPtr< JsonConverter< uint32_t > > get_UInt32Converter()
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateISetInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo)
Definition: json_metadata_services.h:207
static System::SharedPtr< JsonConverter< int64_t > > get_Int64Converter()
static System::SharedPtr< JsonConverter< bool > > get_BooleanConverter()
static System::SharedPtr< JsonConverter< System::SharedPtr< Nodes::JsonObject > > > get_JsonObjectConverter()
static System::SharedPtr< JsonConverter< T > > GetUnsupportedTypeConverter()
Definition: json_metadata_services.h:288
static std::enable_if< System::Constraints::IsCsPointer< T >::value, System::SharedPtr< JsonConverter< Nullable< T > > > >::type GetNullableConverter(System::SharedPtr< JsonSerializerOptions > options)
Definition: json_metadata_services.h:345
static System::SharedPtr< JsonConverter< int32_t > > get_Int32Converter()
static System::SharedPtr< JsonConverter< Memory< uint8_t > > > get_MemoryByteConverter()
static System::SharedPtr< JsonConverter< JsonElement > > get_JsonElementConverter()
static System::SharedPtr< JsonConverter< Guid > > get_GuidConverter()
static std::enable_if<!System::Constraints::IsCsPointer< T >::value, System::SharedPtr< JsonConverter< Nullable< T > > > >::type GetNullableConverter(System::SharedPtr< JsonSerializerOptions > options)
Definition: json_metadata_services.h:329
static std::enable_if<!System::Constraints::IsCsPointer< T >::value, System::SharedPtr< JsonConverter< Nullable< T > > > >::type GetNullableConverter(System::SharedPtr< JsonTypeInfo< T > > underlyingTypeInfo)
Definition: json_metadata_services.h:301
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateListInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo)
Definition: json_metadata_services.h:162
static System::SharedPtr< JsonConverter< System::SharedPtr< Array< uint8_t > > > > get_ByteArrayConverter()
static System::SharedPtr< JsonConverter< System::SharedPtr< Uri > > > get_UriConverter()
static System::SharedPtr< JsonConverter< uint16_t > > get_UInt16Converter()
static System::SharedPtr< JsonConverter< double > > get_DoubleConverter()
static System::SharedPtr< JsonConverter< System::SharedPtr< Object > > > get_ObjectConverter()
static System::SharedPtr< JsonConverter< int8_t > > get_SByteConverter()
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateStackInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo, Action< TCollection, System::SharedPtr< Object > > addFunc)
Definition: json_metadata_services.h:261
static std::enable_if< System::Constraints::IsCsPointer< T >::value, System::SharedPtr< JsonConverter< Nullable< T > > > >::type GetNullableConverter(System::SharedPtr< JsonTypeInfo< T > > underlyingTypeInfo)
Definition: json_metadata_services.h:317
static System::SharedPtr< JsonTypeInfo< TCollection > > CreateIEnumerableInfo(System::SharedPtr< JsonSerializerOptions > options, System::SharedPtr< JsonCollectionInfoValues< TCollection > > collectionInfo)
Definition: json_metadata_services.h:243
static System::SharedPtr< JsonConverter< int16_t > > get_Int16Converter()
Definition: json_object_info_values_of_t.h:45
Definition: json_property_info_values_of_t.h:45
System::SharedPtr< Array< System::SharedPtr< JsonPropertyInfoBase > > >(*)(System::SharedPtr< JsonSerializerOptions >) PropertyMetadataInitializerFn
Definition: json_type_info.h:312
Represents a particular type and provides information about it.
Definition: type_info.h:109
@ Text
Defines color adjustment information for text.
@ Property
Specifies that the member is a property.
@ Field
Specifies that the member is a field.
JsonTypeInfoKind
Definition: json_type_info_kind.h:14
Definition: db_command.h:9
MulticastDelegate< void(Args...)> Action
Delegate type that references methods that have no return value.
Definition: action.h:40
std::enable_if<!IsSmartPtr< T >::value, SmartPtr< T > >::type MakeObject(Args &&... args)
Creates object on heap and returns shared pointer to it.
Definition: smart_ptr.h:1496
A template predicate that determines if type Derived is derived from Base.
Definition: constraints.h:16