Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Data / System / Data / SqlClient / SqlReferenceCollection.cs / 1 / SqlReferenceCollection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- using System; using System.Data; using System.Data.Common; using System.Diagnostics; using System.Data.ProviderBase; namespace System.Data.SqlClient { sealed internal class SqlReferenceCollection : DbReferenceCollection { internal const int DataReaderTag = 1; private int _dataReaderCount; internal bool MayHaveDataReader { get { return (0 != _dataReaderCount); } } override public void Add(object value, int tag) { Debug.Assert(DataReaderTag == tag, "unexpected tag?"); Debug.Assert(value is SqlDataReader, "tag doesn't match object type: SqlDataReader"); _dataReaderCount++; base.AddItem(value, tag); } internal void Deactivate() { if (MayHaveDataReader) { base.Notify(0); _dataReaderCount = 0; } Purge(); } internal SqlDataReader FindLiveReader(SqlCommand command) { // if null == command, will find first live datareader // else will find live datareader assocated with the command if (MayHaveDataReader) { foreach (SqlDataReader dataReader in Filter(DataReaderTag)) { if ((null != dataReader) && !dataReader.IsClosed && ((null == command) || (command == dataReader.Command))) { return dataReader; } } } return null; } override protected bool NotifyItem(int message, int tag, object value) { Debug.Assert(0 == message, "unexpected message?"); Debug.Assert(DataReaderTag == tag, "unexpected tag?"); SqlDataReader rdr = (SqlDataReader)value; if (!rdr.IsClosed) { rdr.CloseReaderFromConnection (); } return false; // remove it from the collection } override public void Remove(object value) { Debug.Assert(value is SqlDataReader, "SqlReferenceCollection.Remove expected a SqlDataReader"); _dataReaderCount--; base.RemoveItem(value); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- using System; using System.Data; using System.Data.Common; using System.Diagnostics; using System.Data.ProviderBase; namespace System.Data.SqlClient { sealed internal class SqlReferenceCollection : DbReferenceCollection { internal const int DataReaderTag = 1; private int _dataReaderCount; internal bool MayHaveDataReader { get { return (0 != _dataReaderCount); } } override public void Add(object value, int tag) { Debug.Assert(DataReaderTag == tag, "unexpected tag?"); Debug.Assert(value is SqlDataReader, "tag doesn't match object type: SqlDataReader"); _dataReaderCount++; base.AddItem(value, tag); } internal void Deactivate() { if (MayHaveDataReader) { base.Notify(0); _dataReaderCount = 0; } Purge(); } internal SqlDataReader FindLiveReader(SqlCommand command) { // if null == command, will find first live datareader // else will find live datareader assocated with the command if (MayHaveDataReader) { foreach (SqlDataReader dataReader in Filter(DataReaderTag)) { if ((null != dataReader) && !dataReader.IsClosed && ((null == command) || (command == dataReader.Command))) { return dataReader; } } } return null; } override protected bool NotifyItem(int message, int tag, object value) { Debug.Assert(0 == message, "unexpected message?"); Debug.Assert(DataReaderTag == tag, "unexpected tag?"); SqlDataReader rdr = (SqlDataReader)value; if (!rdr.IsClosed) { rdr.CloseReaderFromConnection (); } return false; // remove it from the collection } override public void Remove(object value) { Debug.Assert(value is SqlDataReader, "SqlReferenceCollection.Remove expected a SqlDataReader"); _dataReaderCount--; base.RemoveItem(value); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SafeCryptContextHandle.cs
- CacheChildrenQuery.cs
- BitmapSource.cs
- DataObject.cs
- DefaultAssemblyResolver.cs
- ObjectDataSourceDisposingEventArgs.cs
- VectorKeyFrameCollection.cs
- RunInstallerAttribute.cs
- BasicExpressionVisitor.cs
- DataBinder.cs
- ConnectionStringsExpressionBuilder.cs
- TdsParserSessionPool.cs
- Popup.cs
- SafeEventHandle.cs
- Dynamic.cs
- DataGrid.cs
- XPathNode.cs
- Stream.cs
- EnumCodeDomSerializer.cs
- BitmapEffectDrawing.cs
- connectionpool.cs
- WindowsPen.cs
- FullTextLine.cs
- UrlPath.cs
- HttpRequestMessageProperty.cs
- CharacterBufferReference.cs
- InvalidOperationException.cs
- HeaderCollection.cs
- DesignBinding.cs
- StorageInfo.cs
- Window.cs
- DeviceFilterEditorDialog.cs
- ResourceExpressionEditor.cs
- VisualTreeUtils.cs
- HealthMonitoringSectionHelper.cs
- DataBinder.cs
- PathStreamGeometryContext.cs
- ViewgenGatekeeper.cs
- SystemNetworkInterface.cs
- XPathDocumentIterator.cs
- EncoderExceptionFallback.cs
- XmlSignatureProperties.cs
- XmlText.cs
- CommandConverter.cs
- RewritingProcessor.cs
- GlyphInfoList.cs
- StrongNameUtility.cs
- SchemaAttDef.cs
- ConsoleCancelEventArgs.cs
- SqlInternalConnectionSmi.cs
- oledbconnectionstring.cs
- MeasurementDCInfo.cs
- SingleKeyFrameCollection.cs
- Wrapper.cs
- ReceiveCompletedEventArgs.cs
- WsiProfilesElement.cs
- ButtonFlatAdapter.cs
- ButtonColumn.cs
- OleDbParameterCollection.cs
- OletxTransactionFormatter.cs
- WrappedIUnknown.cs
- MultipleViewPatternIdentifiers.cs
- DoubleAnimationBase.cs
- WebPartDisplayModeCollection.cs
- InlinedAggregationOperator.cs
- NestedContainer.cs
- HitTestWithGeometryDrawingContextWalker.cs
- DictionarySectionHandler.cs
- XamlBrushSerializer.cs
- SecurityVersion.cs
- XmlSchemaParticle.cs
- PlatformCulture.cs
- TaskExtensions.cs
- ToolStripDropDownMenu.cs
- SslStream.cs
- HostingEnvironment.cs
- ScalarConstant.cs
- LayoutEvent.cs
- Int32RectConverter.cs
- PropertyToken.cs
- KeyValueSerializer.cs
- XamlValidatingReader.cs
- AdornerDecorator.cs
- XmlObjectSerializerWriteContext.cs
- RefType.cs
- ISO2022Encoding.cs
- DesignerTransactionCloseEvent.cs
- CodeTypeParameter.cs
- DownloadProgressEventArgs.cs
- X509CertificateRecipientClientCredential.cs
- WhitespaceSignificantCollectionAttribute.cs
- DispatcherProcessingDisabled.cs
- LinqMaximalSubtreeNominator.cs
- KeyedHashAlgorithm.cs
- SpnegoTokenProvider.cs
- BatchServiceHost.cs
- UnsettableComboBox.cs
- DataControlButton.cs
- _SSPISessionCache.cs
- BrushConverter.cs