Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Data / System / Data / ProviderBase / DataReaderContainer.cs / 1 / DataReaderContainer.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace System.Data.ProviderBase { using System; using System.Data; using System.Data.Common; using System.Diagnostics; internal abstract class DataReaderContainer { protected readonly IDataReader _dataReader; protected int _fieldCount; static internal DataReaderContainer Create(IDataReader dataReader, bool returnProviderSpecificTypes) { if (returnProviderSpecificTypes) { DbDataReader providerSpecificDataReader = (dataReader as DbDataReader); if (null != providerSpecificDataReader) { return new ProviderSpecificDataReader(dataReader, providerSpecificDataReader); } } return new CommonLanguageSubsetDataReader(dataReader); } protected DataReaderContainer(IDataReader dataReader) { Debug.Assert(null != dataReader, "null dataReader"); _dataReader = dataReader; } internal int FieldCount { get { return _fieldCount; } } internal abstract bool ReturnProviderSpecificTypes { get; } protected abstract int VisibleFieldCount { get; } internal abstract Type GetFieldType(int ordinal); internal abstract object GetValue(int ordinal); internal abstract int GetValues(object[] values); internal string GetName(int ordinal) { string fieldName = _dataReader.GetName(ordinal); Debug.Assert(null != fieldName, "null GetName"); return ((null != fieldName) ? fieldName : ""); } internal DataTable GetSchemaTable() { return _dataReader.GetSchemaTable(); } internal bool NextResult() { _fieldCount = 0; if (_dataReader.NextResult()) { _fieldCount = VisibleFieldCount; return true; } return false; } internal bool Read() { return _dataReader.Read(); } private sealed class ProviderSpecificDataReader : DataReaderContainer { private DbDataReader _providerSpecificDataReader; internal ProviderSpecificDataReader(IDataReader dataReader, DbDataReader dbDataReader) : base(dataReader) { Debug.Assert(null != dataReader, "null dbDataReader"); _providerSpecificDataReader = dbDataReader; _fieldCount = VisibleFieldCount; } internal override bool ReturnProviderSpecificTypes { get { return true; } } protected override int VisibleFieldCount { get { int fieldCount = _providerSpecificDataReader.VisibleFieldCount; Debug.Assert(0 <= fieldCount, "negative FieldCount"); return ((0 <= fieldCount) ? fieldCount : 0); } } internal override Type GetFieldType(int ordinal) { Type fieldType = _providerSpecificDataReader.GetProviderSpecificFieldType(ordinal); Debug.Assert(null != fieldType, "null FieldType"); return fieldType; } internal override object GetValue(int ordinal) { return _providerSpecificDataReader.GetProviderSpecificValue(ordinal); } internal override int GetValues(object[] values) { return _providerSpecificDataReader.GetProviderSpecificValues(values); } } private sealed class CommonLanguageSubsetDataReader : DataReaderContainer { internal CommonLanguageSubsetDataReader(IDataReader dataReader ) : base(dataReader) { _fieldCount = VisibleFieldCount; } internal override bool ReturnProviderSpecificTypes { get { return false; } } protected override int VisibleFieldCount { get { int fieldCount = _dataReader.FieldCount; Debug.Assert(0 <= fieldCount, "negative FieldCount"); return ((0 <= fieldCount) ? fieldCount : 0); } } internal override Type GetFieldType(int ordinal) { return _dataReader.GetFieldType(ordinal); } internal override object GetValue(int ordinal) { return _dataReader.GetValue(ordinal); } internal override int GetValues(object[] values) { return _dataReader.GetValues(values); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InvalidDocumentContentsException.cs
- OleDbStruct.cs
- SQLInt64Storage.cs
- ComponentCollection.cs
- _SslStream.cs
- Privilege.cs
- GridViewSortEventArgs.cs
- StorageComplexTypeMapping.cs
- GridErrorDlg.cs
- XPathBuilder.cs
- Dispatcher.cs
- MultiBindingExpression.cs
- ViewCellRelation.cs
- HighlightComponent.cs
- PseudoWebRequest.cs
- TextBreakpoint.cs
- XmlMemberMapping.cs
- ProfileService.cs
- PtsHost.cs
- Style.cs
- DataTemplateSelector.cs
- wgx_sdk_version.cs
- CommentEmitter.cs
- SiteMapDataSourceView.cs
- GcHandle.cs
- HttpListenerRequestTraceRecord.cs
- DataSvcMapFile.cs
- StorageFunctionMapping.cs
- TreeNodeClickEventArgs.cs
- SqlFunctionAttribute.cs
- AppDomainUnloadedException.cs
- InvokeAction.cs
- SimpleRecyclingCache.cs
- DataGridCommandEventArgs.cs
- GenerateScriptTypeAttribute.cs
- DodSequenceMerge.cs
- BamlLocalizer.cs
- TypeConverterAttribute.cs
- TemplateBuilder.cs
- BCLDebug.cs
- DataGridViewCellLinkedList.cs
- ViewValidator.cs
- PerfCounters.cs
- VisualStateGroup.cs
- SelectedDatesCollection.cs
- SecurityUtils.cs
- safex509handles.cs
- XmlAnyElementAttributes.cs
- AssociatedControlConverter.cs
- EntityDataSourceValidationException.cs
- MethodImplAttribute.cs
- ChannelTraceRecord.cs
- SourceChangedEventArgs.cs
- DataViewSettingCollection.cs
- hresults.cs
- MissingFieldException.cs
- Queue.cs
- Oci.cs
- TabletDeviceInfo.cs
- ByValueEqualityComparer.cs
- EntityContainerRelationshipSet.cs
- SessionStateUtil.cs
- PersonalizationStateInfoCollection.cs
- InputManager.cs
- DataGridViewCheckBoxCell.cs
- ExecutionEngineException.cs
- ListenerConnectionDemuxer.cs
- SecurityElement.cs
- CheckedPointers.cs
- EnumValAlphaComparer.cs
- versioninfo.cs
- XmlSchemaInferenceException.cs
- BehaviorEditorPart.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- HwndTarget.cs
- TraceSection.cs
- PrivilegeNotHeldException.cs
- DebugViewWriter.cs
- GrammarBuilderBase.cs
- CultureInfoConverter.cs
- SelectedDatesCollection.cs
- WindowsToolbar.cs
- SafeNativeMethods.cs
- DirectoryNotFoundException.cs
- VisualState.cs
- BamlResourceSerializer.cs
- X509Certificate2Collection.cs
- Calendar.cs
- NonceCache.cs
- DoubleAverageAggregationOperator.cs
- _SSPIWrapper.cs
- EventLogEntry.cs
- WebSysDisplayNameAttribute.cs
- COM2EnumConverter.cs
- IconBitmapDecoder.cs
- IConvertible.cs
- DirectoryNotFoundException.cs
- DBProviderConfigurationHandler.cs
- ViewRendering.cs
- StatusBarPanelClickEvent.cs