-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDataRow.cs
More file actions
101 lines (86 loc) · 3.83 KB
/
DataRow.cs
File metadata and controls
101 lines (86 loc) · 3.83 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Threading;
using UtilPack;
using System.Threading.Tasks;
using CBAM.SQL.Implementation;
using CBAM.Abstractions.Implementation;
using UtilPack.TabularData;
using CBAM.Abstractions.Implementation.Tabular;
namespace CBAM.SQL.PostgreSQL.Implementation
{
internal sealed class PgSQLDataRowColumn : DataColumnSUKSWithConnectionFunctionality<PostgreSQLProtocol>
{
private readonly DataFormat _dataFormat;
private DataRowObject _backendMessage;
public PgSQLDataRowColumn(
PgSQLDataColumnMetaDataImpl metadata,
Int32 thisStreamIndex,
PgSQLDataRowColumn previousColumn,
PostgreSQLProtocol protocol,
ReservedForStatement reservedForStatement,
RowDescription.FieldData fieldData
) : base( metadata, thisStreamIndex, previousColumn, protocol, reservedForStatement )
{
this._dataFormat = ArgumentValidator.ValidateNotNull( nameof( fieldData ), fieldData ).DataFormat;
}
protected override ValueTask<Object> ReadValueWhileReservedAsync( Int32 byteCount )
{
return this.ConnectionFunctionality.ConvertFromBytes( ( (PgSQLDataColumnMetaDataImpl) this.MetaData ).SQLTypeID, this._dataFormat, this.ReservedForStatement, byteCount );
}
protected override async ValueTask<Int32> ReadByteCountAsync()
{
return await this._backendMessage.ReadColumnByteCount( this.ConnectionFunctionality.MessageIOArgs, this.ConnectionFunctionality.Stream, this.ConnectionFunctionality.CurrentCancellationToken, this.ColumnIndex, this.ConnectionFunctionality.Buffer );
}
protected override async ValueTask<Int32> ReadFromStreamWhileReservedAsync( Byte[] array, Int32 offset, Int32 count )
{
return await this.ConnectionFunctionality.Stream.ReadAsync( array, offset, count, this.ConnectionFunctionality.CurrentCancellationToken );
}
public void Reset( DataRowObject nextRow )
{
this.Reset();
Interlocked.Exchange( ref this._backendMessage, nextRow );
}
}
internal sealed class PgSQLDataRowMetaDataImpl : DataRowMetaDataImpl<AsyncDataColumnMetaData> //, PgSQLDataRowMetaData
{
public PgSQLDataRowMetaDataImpl(
PgSQLDataColumnMetaDataImpl[] columnMetaDatas
)
: base( columnMetaDatas )
{
}
}
internal sealed class PgSQLDataColumnMetaDataImpl : AbstractAsyncDataColumnMetaData, PgSQLDataColumnMetaData
{
private readonly PostgreSQLProtocol _connectionFunctionality;
private readonly DataFormat _dataFormat;
public PgSQLDataColumnMetaDataImpl(
PostgreSQLProtocol connectionFunctionality,
DataFormat dataFormat,
Int32 typeID,
TypeFunctionalityInformation typeInfo,
String label
) : base( typeInfo?.CLRType ?? typeof( String ), label )
{
this._connectionFunctionality = ArgumentValidator.ValidateNotNull( nameof( connectionFunctionality ), connectionFunctionality );
this._dataFormat = dataFormat;
this.SQLTypeID = typeID;
this.TypeInfo = typeInfo;
}
public override Object ChangeType( Object value, Type targetType )
{
var typeInfo = this.TypeInfo;
return typeInfo.Functionality.ChangeTypePgSQLToFramework( typeInfo.DatabaseData, value, targetType );
}
public override ValueTask<Object> ConvertFromBytesAsync( Stream stream, Int32 byteCount )
{
return this._connectionFunctionality.ConvertFromBytes( this.SQLTypeID, this._dataFormat, stream, byteCount );
}
public Int32 SQLTypeID { get; }
private TypeFunctionalityInformation TypeInfo { get; }
}
}