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
- XmlSchemaImport.cs
- ImageCreator.cs
- SrgsText.cs
- DesignRelation.cs
- ClientBuildManagerCallback.cs
- XmlDictionary.cs
- ControlTemplate.cs
- RawKeyboardInputReport.cs
- RotateTransform3D.cs
- FileVersion.cs
- RSAOAEPKeyExchangeDeformatter.cs
- ExpressionPrefixAttribute.cs
- IndexingContentUnit.cs
- HierarchicalDataBoundControl.cs
- InstanceLockedException.cs
- Unit.cs
- DesignConnectionCollection.cs
- DeviceContext.cs
- ArgumentDesigner.xaml.cs
- GridItemPatternIdentifiers.cs
- DBNull.cs
- TypeDescriptor.cs
- TouchDevice.cs
- WebPartCancelEventArgs.cs
- IdentityNotMappedException.cs
- GeneralTransform2DTo3D.cs
- SystemTcpConnection.cs
- WebEventTraceProvider.cs
- ECDiffieHellmanCng.cs
- HostingEnvironment.cs
- FilterException.cs
- ManagementEventArgs.cs
- XamlHttpHandlerFactory.cs
- DataGridClipboardCellContent.cs
- TextEditorSpelling.cs
- KoreanCalendar.cs
- SqlReferenceCollection.cs
- CommunicationObjectAbortedException.cs
- StylusCollection.cs
- BasicBrowserDialog.cs
- TemplateBindingExpressionConverter.cs
- DriveNotFoundException.cs
- ParseElement.cs
- EntityDataSourceWrapperCollection.cs
- OutputWindow.cs
- MultitargetUtil.cs
- PagesSection.cs
- IItemContainerGenerator.cs
- Latin1Encoding.cs
- RepeaterItemCollection.cs
- glyphs.cs
- StringStorage.cs
- HMACSHA256.cs
- FrameworkElement.cs
- OptimizedTemplateContentHelper.cs
- TextParagraphView.cs
- DateTimeFormat.cs
- Utils.cs
- GiveFeedbackEventArgs.cs
- AssemblyAttributesGoHere.cs
- FloatSumAggregationOperator.cs
- WindowsProgressbar.cs
- Brush.cs
- Completion.cs
- ContextMenuStrip.cs
- CreateUserWizardStep.cs
- COSERVERINFO.cs
- AnyReturnReader.cs
- GradientStop.cs
- TimelineClockCollection.cs
- Encoder.cs
- StrongNameMembershipCondition.cs
- OrderedDictionary.cs
- IisTraceListener.cs
- AssociationSetMetadata.cs
- SelectedCellsCollection.cs
- CqlParserHelpers.cs
- SqlNotificationEventArgs.cs
- SmiXetterAccessMap.cs
- invalidudtexception.cs
- HtmlInputRadioButton.cs
- DataAdapter.cs
- ErrorEventArgs.cs
- PersistChildrenAttribute.cs
- System.Data_BID.cs
- SoapIgnoreAttribute.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- TreeView.cs
- AliasGenerator.cs
- BamlVersionHeader.cs
- Base64Encoder.cs
- DispatchWrapper.cs
- ACE.cs
- DllNotFoundException.cs
- DefaultHttpHandler.cs
- SqlDataSourceFilteringEventArgs.cs
- MembershipPasswordException.cs
- EventData.cs
- IHttpResponseInternal.cs
- Int32Rect.cs