Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpServerUtilityBase.cs
- WorkflowRuntimeService.cs
- SyndicationElementExtensionCollection.cs
- MSAANativeProvider.cs
- CompoundFileDeflateTransform.cs
- NameObjectCollectionBase.cs
- BookmarkScopeHandle.cs
- Predicate.cs
- XmlQueryStaticData.cs
- SevenBitStream.cs
- LinqTreeNodeEvaluator.cs
- bidPrivateBase.cs
- PaintEvent.cs
- WpfXamlType.cs
- DataGridViewCellValueEventArgs.cs
- InvokePattern.cs
- DataList.cs
- StrokeFIndices.cs
- regiisutil.cs
- MethodAccessException.cs
- AxHostDesigner.cs
- StyleCollection.cs
- ListViewAutomationPeer.cs
- DetailsViewRow.cs
- StorageBasedPackageProperties.cs
- RandomDelayQueuedSendsAsyncResult.cs
- XmlSchemaAppInfo.cs
- SqlErrorCollection.cs
- TagPrefixInfo.cs
- FormClosedEvent.cs
- AttributedMetaModel.cs
- DataListItemEventArgs.cs
- CqlGenerator.cs
- SizeF.cs
- MailMessageEventArgs.cs
- XPathAxisIterator.cs
- CorrelationActionMessageFilter.cs
- BuildProvider.cs
- ItemContainerGenerator.cs
- ActivityDesignerLayoutSerializers.cs
- GlyphShapingProperties.cs
- WebPartTracker.cs
- Converter.cs
- TaskSchedulerException.cs
- MemberPath.cs
- PropertyToken.cs
- ErrorFormatterPage.cs
- SetUserPreferenceRequest.cs
- DbSource.cs
- COM2ExtendedUITypeEditor.cs
- OleDbFactory.cs
- TranslateTransform.cs
- CalendarData.cs
- InvalidComObjectException.cs
- Rect.cs
- ReadOnlyDataSourceView.cs
- GridViewEditEventArgs.cs
- KnownTypeHelper.cs
- TreeIterator.cs
- ImageKeyConverter.cs
- StreamWriter.cs
- HttpPostClientProtocol.cs
- PlainXmlSerializer.cs
- WebServiceTypeData.cs
- JsonEncodingStreamWrapper.cs
- SqlAliasesReferenced.cs
- SupportsEventValidationAttribute.cs
- PolyLineSegment.cs
- CodeDefaultValueExpression.cs
- _NegotiateClient.cs
- NameScope.cs
- SchemaObjectWriter.cs
- ParserContext.cs
- OrderByQueryOptionExpression.cs
- DoubleAnimationBase.cs
- DataGridViewComponentPropertyGridSite.cs
- TypeDependencyAttribute.cs
- __Filters.cs
- _Connection.cs
- MetaDataInfo.cs
- PenContexts.cs
- DataGridViewTopRowAccessibleObject.cs
- HtmlShimManager.cs
- Identity.cs
- ConnectionManagementSection.cs
- RelationshipConverter.cs
- RemotingException.cs
- CodeTypeParameterCollection.cs
- PathFigureCollectionValueSerializer.cs
- WebPartDisplayModeEventArgs.cs
- ASCIIEncoding.cs
- HttpResponseHeader.cs
- CodeTypeReferenceCollection.cs
- EmbeddedObject.cs
- LinqDataSourceHelper.cs
- OleDbConnection.cs
- EndPoint.cs
- SpellCheck.cs
- MessageTransmitTraceRecord.cs
- HierarchicalDataSourceControl.cs