Esempio n. 1
0
 private object GetNestedObjectValue(object result)
 {
     if (result != DBNull.Value)
     {
         RecordState newSource = result as RecordState;
         if (newSource != null)
         {
             if (newSource.IsNull)
             {
                 result = (object)DBNull.Value;
             }
             else
             {
                 BridgeDataRecord bridgeDataRecord = new BridgeDataRecord(this._shaper, this.Depth + 1);
                 bridgeDataRecord.SetRecordSource(newSource, true);
                 result = (object)bridgeDataRecord;
                 this._currentNestedRecord = bridgeDataRecord;
                 this._currentNestedReader = (BridgeDataReader)null;
             }
         }
         else
         {
             Coordinator <RecordState> coordinator = result as Coordinator <RecordState>;
             if (coordinator != null)
             {
                 BridgeDataReader bridgeDataReader = new BridgeDataReader(this._shaper, coordinator.TypedCoordinatorFactory, this.Depth + 1, (IEnumerator <KeyValuePair <Shaper <RecordState>, CoordinatorFactory <RecordState> > >)null);
                 result = (object)bridgeDataReader;
                 this._currentNestedRecord = (BridgeDataRecord)null;
                 this._currentNestedReader = bridgeDataReader;
             }
         }
     }
     return(result);
 }
        private void SetShaper(Shaper <RecordState> shaper, CoordinatorFactory <RecordState> coordinatorFactory, int depth)
        {
            _shaper             = shaper;
            _coordinatorFactory = coordinatorFactory;
            _dataRecord         = new BridgeDataRecord(shaper, depth);

            if (!_shaper.DataWaiting)
            {
                _shaper.DataWaiting = _shaper.RootEnumerator.MoveNext();
            }

            InitializeHasRows();
        }
Esempio n. 3
0
 private async Task SetShaperAsync(
     Shaper <RecordState> shaper,
     CoordinatorFactory <RecordState> coordinatorFactory,
     int depth,
     CancellationToken cancellationToken)
 {
     this._shaper             = shaper;
     this._coordinatorFactory = coordinatorFactory;
     this._dataRecord         = new BridgeDataRecord(shaper, depth);
     if (!this._shaper.DataWaiting)
     {
         this._shaper.DataWaiting = (await this._shaper.RootEnumerator.MoveNextAsync(cancellationToken).WithCurrentCulture <bool>() ? 1 : 0) != 0;
     }
     this.InitializeHasRows();
 }
        private async Task SetShaperAsync(
            Shaper <RecordState> shaper, CoordinatorFactory <RecordState> coordinatorFactory,
            int depth, CancellationToken cancellationToken)
        {
            _shaper             = shaper;
            _coordinatorFactory = coordinatorFactory;
            _dataRecord         = new BridgeDataRecord(shaper, depth);

            if (!_shaper.DataWaiting)
            {
                _shaper.DataWaiting =
                    await _shaper.RootEnumerator.MoveNextAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
            }

            InitializeHasRows();
        }
Esempio n. 5
0
        private async Task SetShaperAsync(
            Shaper <RecordState> shaper, CoordinatorFactory <RecordState> coordinatorFactory,
            int depth, CancellationToken cancellationToken)
        {
            _shaper             = shaper;
            _coordinatorFactory = coordinatorFactory;
            _dataRecord         = new BridgeDataRecord(shaper, depth);

            if (!_shaper.DataWaiting)
            {
                _shaper.DataWaiting =
                    await _shaper.RootEnumerator.MoveNextAsync(cancellationToken).WithCurrentCulture();
            }

            InitializeHasRows();
        }
Esempio n. 6
0
        private async Task CloseNestedObjectImplicitlyAsync(CancellationToken cancellationToken)
        {
            BridgeDataRecord currentNestedRecord = this._currentNestedRecord;

            if (currentNestedRecord != null)
            {
                this._currentNestedRecord = (BridgeDataRecord)null;
                await currentNestedRecord.CloseImplicitlyAsync(cancellationToken).WithCurrentCulture();
            }
            BridgeDataReader currentNestedReader = this._currentNestedReader;

            if (currentNestedReader == null)
            {
                return;
            }
            this._currentNestedReader = (BridgeDataReader)null;
            await currentNestedReader.CloseImplicitlyAsync(cancellationToken).WithCurrentCulture();
        }
Esempio n. 7
0
        private object CloseNestedObjectImplicitly()
        {
            BridgeDataRecord currentNestedRecord = this._currentNestedRecord;

            if (currentNestedRecord != null)
            {
                this._currentNestedRecord = (BridgeDataRecord)null;
                currentNestedRecord.CloseImplicitly();
            }
            BridgeDataReader currentNestedReader = this._currentNestedReader;

            if (currentNestedReader != null)
            {
                this._currentNestedReader = (BridgeDataReader)null;
                currentNestedReader.CloseImplicitly();
            }
            return((object)null);
        }
        /// <summary>
        ///     An asynchronous version of <see cref="CloseNestedObjectImplicitly" />, which
        ///     Ensure that whatever column we're currently processing is implicitly closed;
        /// </summary>
        private async Task CloseNestedObjectImplicitlyAsync(CancellationToken cancellationToken)
        {
            // it would be nice to use Interlocked.Exchange to avoid multi-thread `race condition risk
            // when the the bridge is being misused by the user accessing it with multiple threads.
            // but this is called frequently enough to have a performance impact
            var currentNestedRecord = _currentNestedRecord;

            if (null != currentNestedRecord)
            {
                _currentNestedRecord = null;
                await currentNestedRecord.CloseImplicitlyAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
            }

            var currentNestedReader = _currentNestedReader;

            if (null != currentNestedReader)
            {
                _currentNestedReader = null;
                await currentNestedReader.CloseImplicitlyAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
            }
        }
 /// <summary>
 ///     For nested objects (records/readers) we have a bit more work to do; this
 ///     method extracts it all out from the main GetValue method so it doesn't
 ///     have to be so big.
 /// </summary>
 /// <param name="result"> </param>
 /// <returns> </returns>
 private object GetNestedObjectValue(object result)
 {
     if (result != DBNull.Value)
     {
         var recordState = result as RecordState;
         if (null != recordState)
         {
             if (recordState.IsNull)
             {
                 result = DBNull.Value;
             }
             else
             {
                 var nestedRecord = new BridgeDataRecord(_shaper, Depth + 1);
                 nestedRecord.SetRecordSource(recordState, true);
                 result = nestedRecord;
                 _currentNestedRecord = nestedRecord;
                 _currentNestedReader = null;
             }
         }
         else
         {
             var coordinator = result as Coordinator <RecordState>;
             if (null != coordinator)
             {
                 var nestedReader = new BridgeDataReader(
                     _shaper, coordinator.TypedCoordinatorFactory, Depth + 1, nextResultShaperInfos: null);
                 result = nestedReader;
                 _currentNestedRecord = null;
                 _currentNestedReader = nestedReader;
             }
             else
             {
                 Debug.Fail("unexpected type of nested object result: " + result.GetType());
             }
         }
     }
     return(result);
 }
        /// <summary>
        ///     Ensure that whatever column we're currently processing is implicitly closed;
        /// </summary>
        private object CloseNestedObjectImplicitly()
        {
            // it would be nice to use Interlocked.Exchange to avoid multi-thread `race condition risk
            // when the the bridge is being misused by the user accessing it with multiple threads.
            // but this is called frequently enough to have a performance impact
            var currentNestedRecord = _currentNestedRecord;

            if (null != currentNestedRecord)
            {
                _currentNestedRecord = null;
                currentNestedRecord.CloseImplicitly();
            }

            var currentNestedReader = _currentNestedReader;

            if (null != currentNestedReader)
            {
                _currentNestedReader = null;
                currentNestedReader.CloseImplicitly();
            }

            return(null);
        }