-
Notifications
You must be signed in to change notification settings - Fork 874
Expand file tree
/
Copy pathDataFormat.cs
More file actions
31 lines (27 loc) · 803 Bytes
/
DataFormat.cs
File metadata and controls
31 lines (27 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace Npgsql.Internal;
[Experimental(NpgsqlDiagnostics.ConvertersExperimental)]
public enum DataFormat : byte
{
Binary,
Text
}
static class DataFormatUtils
{
public static DataFormat Create(short formatCode)
=> formatCode switch
{
0 => DataFormat.Text,
1 => DataFormat.Binary,
_ => throw new ArgumentOutOfRangeException(nameof(formatCode), formatCode, "Unknown postgres format code, please file a bug,")
};
public static short ToFormatCode(this DataFormat dataFormat)
=> dataFormat switch
{
DataFormat.Text => 0,
DataFormat.Binary => 1,
_ => throw new UnreachableException()
};
}