Exemplo n.º 1
0
        /// <summary>
        /// Configures the next stack frame for a polymorphic converter.
        /// </summary>
        public JsonConverter InitializePolymorphicReEntry(Type runtimeType, JsonSerializerOptions options)
        {
            Debug.Assert(PolymorphicSerializationState == PolymorphicSerializationState.None);

            // For perf, avoid the dictionary lookup in GetOrAddJsonTypeInfo() for every element of a collection
            // if the current element is the same type as the previous element.
            if (PolymorphicJsonTypeInfo?.PropertyType != runtimeType)
            {
                JsonTypeInfo typeInfo = options.GetTypeInfoInternal(runtimeType);
                PolymorphicJsonTypeInfo = typeInfo.PropertyInfoForTypeInfo;
            }

            PolymorphicSerializationState = PolymorphicSerializationState.PolymorphicReEntryStarted;
            return(PolymorphicJsonTypeInfo.EffectiveConverter);
        }