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
- ResizingMessageFilter.cs
- EventHandlers.cs
- ListViewInsertEventArgs.cs
- QilCloneVisitor.cs
- CustomSignedXml.cs
- SymmetricKeyWrap.cs
- TrustManager.cs
- ActivationServices.cs
- ConsumerConnectionPointCollection.cs
- MinimizableAttributeTypeConverter.cs
- PerformanceCounterLib.cs
- ListManagerBindingsCollection.cs
- DataSourceCache.cs
- MatrixAnimationUsingPath.cs
- HyperlinkAutomationPeer.cs
- SmtpAuthenticationManager.cs
- ConstructorBuilder.cs
- ConnectionPoolManager.cs
- NullRuntimeConfig.cs
- XPathAxisIterator.cs
- Math.cs
- HMACSHA512.cs
- _AcceptOverlappedAsyncResult.cs
- SqlReferenceCollection.cs
- CharAnimationUsingKeyFrames.cs
- PageBuildProvider.cs
- CompositeDuplexBindingElementImporter.cs
- Internal.cs
- SymmetricAlgorithm.cs
- KnownTypesProvider.cs
- RegionData.cs
- BaseHashHelper.cs
- BackStopAuthenticationModule.cs
- StatusBarItemAutomationPeer.cs
- DataServiceHost.cs
- ListDictionaryInternal.cs
- MultiAsyncResult.cs
- VScrollBar.cs
- ConfigurationStrings.cs
- WSSecureConversationDec2005.cs
- SourceFilter.cs
- NativeWindow.cs
- GeneralTransform2DTo3D.cs
- Types.cs
- XD.cs
- MasterPageParser.cs
- XsltException.cs
- WindowsNonControl.cs
- TextLineResult.cs
- EllipseGeometry.cs
- Stack.cs
- DesignTimeValidationFeature.cs
- _NativeSSPI.cs
- XappLauncher.cs
- XmlSchemaException.cs
- WinEventWrap.cs
- TypeGeneratedEventArgs.cs
- XamlFilter.cs
- BuildDependencySet.cs
- GlyphTypeface.cs
- Token.cs
- SiteMapDataSourceView.cs
- MetadataUtil.cs
- InkCollectionBehavior.cs
- keycontainerpermission.cs
- XmlQuerySequence.cs
- FileDataSourceCache.cs
- CodeVariableReferenceExpression.cs
- BuildProvider.cs
- BuildProviderCollection.cs
- SQLMoneyStorage.cs
- CodeDomConfigurationHandler.cs
- JournalNavigationScope.cs
- SessionState.cs
- OdbcException.cs
- WinInetCache.cs
- DataGridDetailsPresenter.cs
- DataBindingValueUIHandler.cs
- DbProviderSpecificTypePropertyAttribute.cs
- RoleGroup.cs
- CodeAccessPermission.cs
- loginstatus.cs
- UnhandledExceptionEventArgs.cs
- CellTreeNodeVisitors.cs
- DesignerSerializerAttribute.cs
- Messages.cs
- XPathBuilder.cs
- Switch.cs
- DbSourceParameterCollection.cs
- XmlNodeReader.cs
- RegexRunnerFactory.cs
- RoutedUICommand.cs
- Point3DCollectionConverter.cs
- WebContentFormatHelper.cs
- _NegoStream.cs
- StatusBarPanel.cs
- EncryptedPackage.cs
- Literal.cs
- SuppressIldasmAttribute.cs
- SupportsEventValidationAttribute.cs