Beispiel #1
0
        private void WriteStringSuppressFalse(ref ReadOnlySpan <byte> propertyName, DateTime value)
        {
            int propertyIdx = JsonWriterHelper.NeedsEscaping(propertyName);

            Debug.Assert(propertyIdx >= -1 && propertyIdx < int.MaxValue / 2);

            if (propertyIdx != -1)
            {
                WriteStringEscapeProperty(ref propertyName, value, propertyIdx);
            }
            else
            {
                WriteStringByOptions(ref propertyName, value);
            }
        }
Beispiel #2
0
        private void WriteStringSuppressFalse(ref ReadOnlySpan <char> value)
        {
            int valueIdx = JsonWriterHelper.NeedsEscaping(value);

            Debug.Assert(valueIdx >= -1 && valueIdx < int.MaxValue / 2);

            if (valueIdx != -1)
            {
                WriteStringEscapeValue(ref value, valueIdx);
            }
            else
            {
                WriteStringByOptions(ref value);
            }
        }
        private void WriteLiteralSuppressFalse(ref ReadOnlySpan <char> propertyName, ref ReadOnlySpan <byte> value)
        {
            int propertyIdx = JsonWriterHelper.NeedsEscaping(propertyName);

            Debug.Assert(propertyIdx >= -1 && propertyIdx < int.MaxValue / 2);

            if (propertyIdx != -1)
            {
                WriteLiteralEscapeProperty(ref propertyName, ref value, propertyIdx);
            }
            else
            {
                WriteLiteralByOptions(ref propertyName, ref value);
            }
        }
        private void WriteStringSuppressFalse(ref ReadOnlySpan <byte> propertyName, ref ReadOnlySpan <char> value)
        {
            int valueIdx    = JsonWriterHelper.NeedsEscaping(value);
            int propertyIdx = JsonWriterHelper.NeedsEscaping(propertyName);

            Debug.Assert(valueIdx >= -1 && valueIdx < int.MaxValue / 2);
            Debug.Assert(propertyIdx >= -1 && propertyIdx < int.MaxValue / 2);

            // Equivalent to: valueIdx != -1 || propertyIdx != -1
            if (valueIdx + propertyIdx != -2)
            {
                WriteStringEscapePropertyOrValue(ref propertyName, ref value, propertyIdx, valueIdx);
            }
            else
            {
                WriteStringByOptions(ref propertyName, ref value);
            }
        }