Esempio n. 1
0
        public void InitializeRoot(Type type, JsonSerializerOptions options)
        {
            JsonClassInfo jsonClassInfo = options.GetOrAddClass(type);

            Debug.Assert(jsonClassInfo.ClassType != ClassType.Invalid);

            Current.JsonClassInfo = jsonClassInfo;

            // The initial JsonPropertyInfo will be used to obtain the converter.
            Current.JsonPropertyInfo = jsonClassInfo.PolicyProperty !;

            if (options.ReferenceHandling.ShouldReadPreservedReferences())
            {
                ReferenceResolver = new DefaultReferenceResolver(writing: false);
            }
        }
Esempio n. 2
0
        public void Initialize(Type type, JsonSerializerOptions options, bool supportContinuation)
        {
            JsonClassInfo jsonClassInfo = options.GetOrAddClass(type);

            Current.JsonClassInfo = jsonClassInfo;

            // The initial JsonPropertyInfo will be used to obtain the converter.
            Current.JsonPropertyInfo = jsonClassInfo.PropertyInfoForClassInfo;

            if (options.ReferenceHandling.ShouldReadPreservedReferences())
            {
                ReferenceResolver = new DefaultReferenceResolver(writing: false);
            }

            SupportContinuation = supportContinuation;
        }
Esempio n. 3
0
        /// <summary>
        /// Initialize the state without delayed initialization of the JsonClassInfo.
        /// </summary>
        public void Initialize(Type type, JsonSerializerOptions options, bool supportContinuation)
        {
            JsonClassInfo jsonClassInfo = options.GetOrAddClass(type);

            Current.JsonClassInfo = jsonClassInfo;

            if ((jsonClassInfo.ClassType & (ClassType.Enumerable | ClassType.Dictionary)) == 0)
            {
                Current.DeclaredJsonPropertyInfo = jsonClassInfo.PropertyInfoForClassInfo;
            }

            if (options.ReferenceHandling.ShouldWritePreservedReferences())
            {
                ReferenceResolver = new DefaultReferenceResolver(writing: true);
            }

            SupportContinuation = supportContinuation;
        }