Beispiel #1
0
 // The factory method is JsonSerializationCodeGen.CreateTypeInfo.
 internal JsonTypeInfo(NullableTypeTree t, int number, string name, IReadOnlyList <string>?previousNames, JsonCodeGenHandler?writeHandler)
 {
     Debug.Assert(number >= 0 && t.IsNormalNull);
     Type = t;
     // We cannot use the oblivious type (that may have computed for the writeHandler) here because
     // value tuple must use their generic form (not the parentheses) in switch case.
     GenCSharpName = t.Type.ToCSharpName(useValueTupleParentheses: false);
     Number        = number;
     NumberName    = number.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
     TypeSpecOrder = -1.0f;
     // By default, the ECMAScriptStandardJsonName is the JsonName.
     NonNullableJsonName = name;
     NonNullableECMAScriptStandardJsonName = new ECMAScriptStandardJsonName(name, false);
     NonNullablePreviousJsonNames          = previousNames ?? Array.Empty <string>();
     if (t.Type.IsValueType)
     {
         NonNullHandler = new HandlerForValueType(this);
     }
     else
     {
         var n = new HandlerForReferenceType(this);
         NonNullHandler = n.ToNonNullHandler();
     }
     GenericWriteHandler = writeHandler ?? NonNullHandler;
 }
 internal HandlerForNullableValueType(HandlerForValueType h)
 {
     _nonNullHandler = h;
 }