/// <summary>
 /// Initializes a new instance of the <see cref="SerializationRootConverter"/> class.
 /// </summary>
 /// <param name="converter">The expression converter (to set types).</param>
 /// <param name="anonTypeConverter">The anonymous type converter.</param>
 public SerializationRootConverter(
     SerializableExpressionConverter converter,
     AnonTypeConverter anonTypeConverter)
 {
     this.converter         = converter;
     this.anonTypeConverter = anonTypeConverter;
 }
        /// <summary>
        /// Prepares the options with the converter.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <returns>The options with the converter added.</returns>
        private JsonSerializerOptions PrepareOptions(JsonSerializerOptions options)
        {
            options = options ?? new JsonSerializerOptions
            {
                IgnoreNullValues         = true,
                IgnoreReadOnlyProperties = true,
            };

            var expressionConverter = new SerializableExpressionConverter();
            var anonTypeConverter   = new AnonTypeConverter();
            var rootConverter       = new SerializationRootConverter(expressionConverter, anonTypeConverter);

            options.Converters.Add(expressionConverter);
            options.Converters.Add(rootConverter);
            options.Converters.Add(new MemberBindingExprConverter());
            options.Converters.Add(anonTypeConverter);

            return(options);
        }