Summary

Class:CBAM.Abstractions.Implementation.Tabular.DataColumnSUKSWithConnectionFunctionality`1
Assembly:CBAM.Abstractions.Implementation.Tabular
File(s):/repo-dir/contents/Source/Code/CBAM.Abstractions.Implementation.Tabular/DataColumn.cs
Covered lines:8
Uncovered lines:0
Coverable lines:8
Total lines:111
Line coverage:100%

Coverage History

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
.ctor(...)101%0%
ReadValueAsync(...)101%0%
DoReadFromStreamAsync(...)101%0%

File(s)

/repo-dir/contents/Source/Code/CBAM.Abstractions.Implementation.Tabular/DataColumn.cs

#LineLine coverage
 1/*
 2 * Copyright 2017 Stanislav Muhametsin. All rights Reserved.
 3 *
 4 * Licensed  under the  Apache License,  Version 2.0  (the "License");
 5 * you may not use  this file  except in  compliance with the License.
 6 * You may obtain a copy of the License at
 7 *
 8 *   http://www.apache.org/licenses/LICENSE-2.0
 9 *
 10 * Unless required by applicable law or agreed to in writing, software
 11 * distributed  under the  License is distributed on an "AS IS" BASIS,
 12 * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
 13 * implied.
 14 *
 15 * See the License for the specific language governing permissions and
 16 * limitations under the License.
 17 */
 18using System;
 19using System.Threading.Tasks;
 20using UtilPack;
 21using UtilPack.TabularData;
 22
 23namespace CBAM.Abstractions.Implementation.Tabular
 24{
 25   /// <summary>
 26   /// This class extends <see cref="DataColumnSUKS"/> to use <see cref="ConnectionFunctionalitySU"/> to reserve it when
 27   /// </summary>
 28   /// <typeparam name="TConnectionFunctionality">The real type of <see cref="ConnectionFunctionalitySU"/>.</typeparam>
 29   /// <seealso cref="ConnectionFunctionalitySU.UseStreamWithinStatementAsync(ReservedForStatement, Func{Task}, Boolean)
 30   /// <seealso cref="ConnectionFunctionalitySU.UseStreamWithinStatementAsync{T}(ReservedForStatement, Func{ValueTask{T}
 31   public abstract class DataColumnSUKSWithConnectionFunctionality<TConnectionFunctionality> : DataColumnSUKS
 32      where TConnectionFunctionality : class, ConnectionFunctionalitySU
 33   {
 34
 35      /// <summary>
 36      /// Creates new instance of <see cref="DataColumnSUKSWithConnectionFunctionality{TConnectionFunctionality}"/> with
 37      /// </summary>
 38      /// <param name="metadata">The <see cref="DataColumnMetaData"/> of this data column.</param>
 39      /// <param name="columnIndex">The index of this column within the <see cref="AsyncDataRow"/>.</param>
 40      /// <param name="previousColumn">The column at previous index within the <see cref="AsyncDataRow"/>.</param>
 41      /// <param name="connectionFunctionality">The <see cref="ConnectionFunctionalitySU{TStatement, TStatementInformati
 42      /// <param name="reservedForStatement">The <see cref="Implementation.ReservedForStatement"/> object that is used i
 43      /// <exception cref="ArgumentNullException">If any of <paramref name="metadata"/>, <paramref name="connectionFunct
 44      public DataColumnSUKSWithConnectionFunctionality(
 45         DataColumnMetaData metadata,
 46         Int32 columnIndex,
 47         AsyncDataColumn previousColumn,
 48         TConnectionFunctionality connectionFunctionality,
 49         ReservedForStatement reservedForStatement
 10650         ) : base( metadata, columnIndex, previousColumn )
 51      {
 10652         this.ConnectionFunctionality = ArgumentValidator.ValidateNotNull( nameof( connectionFunctionality ), connection
 10653         this.ReservedForStatement = ArgumentValidator.ValidateNotNull( nameof( reservedForStatement ), reservedForState
 10754      }
 55
 56      /// <summary>
 57      /// Gets the <see cref="ConnectionFunctionalitySU{TStatement, TStatementInformation, TStatementCreationArgs, TEnum
 58      /// </summary>
 59      /// <value>The <see cref="ConnectionFunctionalitySU{TStatement, TStatementInformation, TStatementCreationArgs, TEn
 200560      protected TConnectionFunctionality ConnectionFunctionality { get; }
 61
 62      /// <summary>
 63      /// Gets the <see cref="Implementation.ReservedForStatement"/> object of this data column.
 64      /// </summary>
 65      /// <value>The <see cref="Implementation.ReservedForStatement"/> object of this data column.</value>
 66366      protected ReservedForStatement ReservedForStatement { get; }
 67
 68      /// <summary>
 69      /// Implements <see cref="DataColumnSUKS.ReadValueAsync(int)"/> and will call <see cref="ReadValueWhileReservedAsy
 70      /// </summary>
 71      /// <param name="byteCount">The size of data, in bytes.</param>
 72      /// <returns>Asynchronously returns deserialized value.</returns>
 73      /// <seealso cref="DataColumnSUKS.ReadValueAsync(int)"/>
 74      /// <seealso cref="ConnectionFunctionalitySU{TStatement, TStatementInformation, TStatementCreationArgs, TEnumerabl
 75      protected override ValueTask<Object> ReadValueAsync( Int32 byteCount )
 76      {
 65677         return this.ConnectionFunctionality.UseStreamWithinStatementAsync( this.ReservedForStatement, () => this.ReadVa
 78      }
 79
 80      /// <summary>
 81      /// Implements <see cref="DataColumnSUKS.DoReadFromStreamAsync(byte[], int, int)"/> and will call <see cref="ReadF
 82      /// </summary>
 83      /// <param name="array">The byte array where to read the data to.</param>
 84      /// <param name="offset">The offset in <paramref name="array"/> where to start writing bytes.</param>
 85      /// <param name="count">The maximum amount of bytes to write.</param>
 86      /// <returns>Asynchronously returns the amount of bytes read.</returns>
 87      /// <seealso cref="DataColumnSUKS.DoReadFromStreamAsync(byte[], int, int)"/>
 88      /// <seealso cref="ConnectionFunctionalitySU{TStatement, TStatementInformation, TStatementCreationArgs, TEnumerabl
 89      protected override ValueTask<Int32> DoReadFromStreamAsync( Byte[] array, Int32 offset, Int32 count )
 90      {
 1091         return this.ConnectionFunctionality.UseStreamWithinStatementAsync( this.ReservedForStatement, () => this.ReadFr
 92      }
 93
 94      /// <summary>
 95      /// Derived classes should implement this method to read binary data from underlying stream.
 96      /// </summary>
 97      /// <param name="array">The byte array where to read the data to.</param>
 98      /// <param name="offset">The offset in <paramref name="array"/> where to start writing bytes.</param>
 99      /// <param name="count">The maximum amount of bytes to write.</param>
 100      /// <returns>Asynchronously returns the amount of bytes read.</returns>
 101      protected abstract ValueTask<Int32> ReadFromStreamWhileReservedAsync( Byte[] array, Int32 offset, Int32 count );
 102
 103      /// <summary>
 104      /// Derived classes should implement this method to deserialize binary data into CLR object.
 105      /// </summary>
 106      /// <param name="byteCount">The size of the data, in bytes.</param>
 107      /// <returns>Asynchronously returns deserialized value.</returns>
 108      protected abstract ValueTask<Object> ReadValueWhileReservedAsync( Int32 byteCount );
 109
 110   }
 111}