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
- StrongNameUtility.cs
- XmlExpressionDumper.cs
- ComPlusInstanceContextInitializer.cs
- XmlDataSourceNodeDescriptor.cs
- SQLDecimal.cs
- PriorityBindingExpression.cs
- DebuggerAttributes.cs
- RenderTargetBitmap.cs
- XPathParser.cs
- TimelineGroup.cs
- MenuTracker.cs
- WindowsStartMenu.cs
- FieldBuilder.cs
- TemplateNodeContextMenu.cs
- StateRuntime.cs
- _HelperAsyncResults.cs
- PopupEventArgs.cs
- DeploymentSection.cs
- BufferedWebEventProvider.cs
- CustomAssemblyResolver.cs
- AngleUtil.cs
- DecoratedNameAttribute.cs
- InternalDuplexChannelListener.cs
- SinglePhaseEnlistment.cs
- OperationContractAttribute.cs
- _StreamFramer.cs
- ContractMapping.cs
- SmtpFailedRecipientsException.cs
- ZipIOExtraField.cs
- PseudoWebRequest.cs
- ServiceDeploymentInfo.cs
- ThreadExceptionDialog.cs
- TableCellAutomationPeer.cs
- DateTimeOffsetConverter.cs
- controlskin.cs
- DocumentReference.cs
- Ipv6Element.cs
- ScriptResourceAttribute.cs
- AsyncCompletedEventArgs.cs
- SslStream.cs
- FactoryMaker.cs
- DefaultAuthorizationContext.cs
- CapabilitiesAssignment.cs
- MenuScrollingVisibilityConverter.cs
- MediaTimeline.cs
- UserUseLicenseDictionaryLoader.cs
- ListControl.cs
- wgx_exports.cs
- Wizard.cs
- indexingfiltermarshaler.cs
- ReadOnlyDictionary.cs
- NamespaceInfo.cs
- InstanceHandle.cs
- UriWriter.cs
- BindingMemberInfo.cs
- XmlMessageFormatter.cs
- FormsIdentity.cs
- RuntimeIdentifierPropertyAttribute.cs
- HtmlShimManager.cs
- VirtualPathUtility.cs
- TileBrush.cs
- UTF32Encoding.cs
- ServiceChannelFactory.cs
- NoClickablePointException.cs
- Decorator.cs
- DetailsViewRowCollection.cs
- ObjectDataSourceMethodEventArgs.cs
- ToolStripDropDownClosedEventArgs.cs
- XdrBuilder.cs
- ThousandthOfEmRealDoubles.cs
- AliasExpr.cs
- WebPartCancelEventArgs.cs
- SystemParameters.cs
- AssociationTypeEmitter.cs
- SupportingTokenChannel.cs
- CodeRemoveEventStatement.cs
- ISAPIRuntime.cs
- WebPartDisplayModeCancelEventArgs.cs
- CompoundFileReference.cs
- DoubleUtil.cs
- XmlSchemaException.cs
- InvalidAsynchronousStateException.cs
- Point3DKeyFrameCollection.cs
- Label.cs
- ConfigXmlSignificantWhitespace.cs
- PropertyOrder.cs
- FieldNameLookup.cs
- GlyphRun.cs
- DefaultTraceListener.cs
- APCustomTypeDescriptor.cs
- ArraySortHelper.cs
- KeyInterop.cs
- DataMemberConverter.cs
- InheritanceUI.cs
- VideoDrawing.cs
- QuaternionKeyFrameCollection.cs
- AsyncCodeActivityContext.cs
- SubordinateTransaction.cs
- TraceData.cs
- CompiledIdentityConstraint.cs