JsonParameterInfo
using System.Reflection;
using System.Text.Json.Serialization;
namespace System.Text.Json
{
internal abstract class JsonParameterInfo
{
private JsonClassInfo _runtimeClassInfo;
public JsonConverter ConverterBase { get; set; }
public object DefaultValue { get; set; }
public bool IgnoreDefaultValuesOnRead { get; set; }
public JsonSerializerOptions Options { get; set; }
public byte[] NameAsUtf8Bytes { get; set; }
public JsonNumberHandling? NumberHandling { get; set; }
public int Position { get; set; }
public JsonClassInfo RuntimeClassInfo {
get {
if (_runtimeClassInfo == null)
_runtimeClassInfo = Options.GetOrAddClass(RuntimePropertyType);
return _runtimeClassInfo;
}
}
internal Type RuntimePropertyType { get; set; }
public bool ShouldDeserialize { get; set; }
public virtual void Initialize(Type runtimePropertyType, ParameterInfo parameterInfo, JsonPropertyInfo matchingProperty, JsonSerializerOptions options)
{
RuntimePropertyType = runtimePropertyType;
Position = parameterInfo.Position;
NameAsUtf8Bytes = matchingProperty.NameAsUtf8Bytes;
Options = options;
ShouldDeserialize = true;
ConverterBase = matchingProperty.ConverterBase;
IgnoreDefaultValuesOnRead = matchingProperty.IgnoreDefaultValuesOnRead;
NumberHandling = matchingProperty.NumberHandling;
}
public static JsonParameterInfo CreateIgnoredParameterPlaceholder(JsonPropertyInfo matchingProperty)
{
JsonParameterInfo<sbyte> jsonParameterInfo = new JsonParameterInfo<sbyte>();
jsonParameterInfo.RuntimePropertyType = typeof(sbyte);
jsonParameterInfo.NameAsUtf8Bytes = matchingProperty.NameAsUtf8Bytes;
return jsonParameterInfo;
}
}
}