Пример #1
0
        public override async Task WriteBackendValue(
            DataFormat dataFormat,
            PgSQLTypeDatabaseData boundData,
            BackendABIHelper helper,
            StreamWriterWithResizableBufferAndLimitedSize stream,
            Object value,
            BackendSizeInfo sizeInfo,
            Boolean isArrayElement
            )
        {
            switch (dataFormat)
            {
            case DataFormat.Text:
                await this.WriteArrayText(boundData, helper, stream, (Array)value, sizeInfo);

                break;

            case DataFormat.Binary:
                await this.WriteArrayBinary(boundData, helper, stream, (Array)value, sizeInfo);

                break;

            default:
                throw new NotSupportedException($"Data format {dataFormat} is not recognized.");
            }
        }
Пример #2
0
        public override async Task WriteBackendValue(
            DataFormat dataFormat,
            PgSQLTypeDatabaseData boundData,
            BackendABIHelper helper,
            StreamWriterWithResizableBufferAndLimitedSize stream,
            Object value,
            BackendSizeInfo additionalInfoFromSize,
            Boolean isArrayElement
            )
        {
            // No truly async support for serializing JTokens in Newtonsoft, at least yet, so let's do it ourselves
            switch (dataFormat)
            {
            case DataFormat.Text:
                await stream.WriteJSONTTokenAsync(helper.Encoding, (JToken)value);

                break;

            case DataFormat.Binary:
                throw new InvalidOperationException("This data format is not supported");

            default:
                throw new NotSupportedException($"Unrecognized data format: ${dataFormat}.");
            }
        }