Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / SqlClient / SqlReferenceCollection.cs / 1305376 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BindingExpressionBase.cs
- PartialClassGenerationTaskInternal.cs
- EntityTypeEmitter.cs
- MetaModel.cs
- PackageDigitalSignature.cs
- NullableBoolConverter.cs
- CLSCompliantAttribute.cs
- TemplateBindingExtension.cs
- IOException.cs
- AppDomainProtocolHandler.cs
- InkCanvasFeedbackAdorner.cs
- TableLayoutStyle.cs
- VariableQuery.cs
- Line.cs
- FigureHelper.cs
- PartManifestEntry.cs
- DbgCompiler.cs
- BaseComponentEditor.cs
- Transactions.cs
- DescriptionAttribute.cs
- XPathNavigatorReader.cs
- SoapSchemaImporter.cs
- RemotingException.cs
- Int32Rect.cs
- QuaternionValueSerializer.cs
- NativeRecognizer.cs
- FilterableAttribute.cs
- CapabilitiesState.cs
- ZoneLinkButton.cs
- ToolStripSplitButton.cs
- Compiler.cs
- IisTraceListener.cs
- Interfaces.cs
- PropertyGeneratedEventArgs.cs
- SynchronizedInputProviderWrapper.cs
- SpanIndex.cs
- DataSetMappper.cs
- CodeDOMUtility.cs
- HostSecurityManager.cs
- TableCell.cs
- IsolatedStorageFileStream.cs
- InputBindingCollection.cs
- SoapEnvelopeProcessingElement.cs
- BaseTemplateBuildProvider.cs
- ErrorFormatterPage.cs
- SqlConnectionPoolProviderInfo.cs
- PointKeyFrameCollection.cs
- DataGridViewCellStyleChangedEventArgs.cs
- TimeSpanConverter.cs
- ACL.cs
- WinEventHandler.cs
- RightsManagementEncryptedStream.cs
- RuntimeHandles.cs
- XmlILOptimizerVisitor.cs
- InstallerTypeAttribute.cs
- HtmlHead.cs
- ButtonBase.cs
- DebugView.cs
- PointAnimationUsingKeyFrames.cs
- ComboBox.cs
- RequiredFieldValidator.cs
- SafeReversePInvokeHandle.cs
- FormParameter.cs
- SystemParameters.cs
- PrimitiveDataContract.cs
- SimpleTypeResolver.cs
- JournalEntry.cs
- DoubleAnimationUsingPath.cs
- TheQuery.cs
- GraphicsContainer.cs
- FlatButtonAppearance.cs
- figurelength.cs
- CFStream.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- RuntimeTransactionHandle.cs
- ExtensionFile.cs
- SystemWebCachingSectionGroup.cs
- SwitchElementsCollection.cs
- EventlogProvider.cs
- Debug.cs
- Int16AnimationUsingKeyFrames.cs
- SimpleType.cs
- XmlHierarchicalEnumerable.cs
- SymbolUsageManager.cs
- EastAsianLunisolarCalendar.cs
- HtmlLink.cs
- CaseInsensitiveComparer.cs
- XmlProcessingInstruction.cs
- OleAutBinder.cs
- InputMethodStateTypeInfo.cs
- ImageSource.cs
- BinHexEncoder.cs
- StagingAreaInputItem.cs
- HatchBrush.cs
- SoapFault.cs
- WebScriptMetadataFormatter.cs
- MsmqInputSessionChannelListener.cs
- MenuItem.cs
- CacheChildrenQuery.cs
- MimeParameterWriter.cs