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
- _AuthenticationState.cs
- QueryReaderSettings.cs
- PreservationFileReader.cs
- SafeEventHandle.cs
- SecurityDescriptor.cs
- StringConcat.cs
- EntryWrittenEventArgs.cs
- GridPatternIdentifiers.cs
- UndoManager.cs
- SQLInt16Storage.cs
- LogSwitch.cs
- XmlAtomicValue.cs
- SerializationEventsCache.cs
- SuppressMergeCheckAttribute.cs
- Funcletizer.cs
- Grant.cs
- PrintingPermission.cs
- CssTextWriter.cs
- ConfigurationValues.cs
- NestPullup.cs
- WebRequestModulesSection.cs
- RegularExpressionValidator.cs
- StoreItemCollection.Loader.cs
- ThreadStateException.cs
- EmptyEnumerable.cs
- SafeTokenHandle.cs
- CodeMemberMethod.cs
- RenamedEventArgs.cs
- TextRenderer.cs
- _LocalDataStore.cs
- WindowsFormsHostPropertyMap.cs
- TemplateNameScope.cs
- ClientTargetSection.cs
- DataGridViewColumnCollectionEditor.cs
- SiblingIterators.cs
- DataGridViewToolTip.cs
- ClientEventManager.cs
- ItemContainerGenerator.cs
- PingReply.cs
- LogicalTreeHelper.cs
- UserUseLicenseDictionaryLoader.cs
- TemplatePropertyEntry.cs
- AutoResetEvent.cs
- ColorMatrix.cs
- MLangCodePageEncoding.cs
- SqlRewriteScalarSubqueries.cs
- ToolStripScrollButton.cs
- HttpContextWrapper.cs
- DependencyProperty.cs
- TriState.cs
- PackageStore.cs
- QueryStringParameter.cs
- DynamicMethod.cs
- GridItem.cs
- EncoderExceptionFallback.cs
- TakeOrSkipQueryOperator.cs
- PreloadedPackages.cs
- TypeGenericEnumerableViewSchema.cs
- GeneratedContractType.cs
- EmptyElement.cs
- CustomPopupPlacement.cs
- DynamicDataResources.Designer.cs
- ReaderWriterLockWrapper.cs
- tabpagecollectioneditor.cs
- HttpCookieCollection.cs
- AvTraceFormat.cs
- HiddenFieldPageStatePersister.cs
- Aes.cs
- ApplicationInfo.cs
- EventLogger.cs
- GroupByQueryOperator.cs
- ThreadAbortException.cs
- CryptoStream.cs
- MetadataSource.cs
- DataGridPageChangedEventArgs.cs
- DbConnectionFactory.cs
- BitVec.cs
- ResourceDefaultValueAttribute.cs
- RegexMatch.cs
- TimeSpanValidator.cs
- XmlSchemaComplexContentRestriction.cs
- TableCell.cs
- GiveFeedbackEventArgs.cs
- IteratorFilter.cs
- Context.cs
- FieldBuilder.cs
- XmlSchemaRedefine.cs
- XPathQilFactory.cs
- DocumentGridContextMenu.cs
- LinearKeyFrames.cs
- TypeInfo.cs
- DictionarySectionHandler.cs
- _LocalDataStoreMgr.cs
- JapaneseCalendar.cs
- GetIsBrowserClientRequest.cs
- HttpServerUtilityBase.cs
- FocusChangedEventArgs.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- ProjectionPlan.cs
- LessThanOrEqual.cs