Code:
/ 4.0 / 4.0 / 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. //------------------------------------------------------------------------------ //// 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
- ParentQuery.cs
- SafeTokenHandle.cs
- QilLiteral.cs
- Stylesheet.cs
- AccessDataSourceView.cs
- SimpleHandlerBuildProvider.cs
- FixedLineResult.cs
- BuildProviderCollection.cs
- Classification.cs
- CharacterBuffer.cs
- XmlUtil.cs
- UserControlCodeDomTreeGenerator.cs
- XmlSerializerNamespaces.cs
- CachingHintValidation.cs
- PropertyGroupDescription.cs
- DataGridParentRows.cs
- Stroke.cs
- XmlRawWriterWrapper.cs
- HtmlInputRadioButton.cs
- Image.cs
- HandleScope.cs
- Matrix3DConverter.cs
- RelationshipDetailsCollection.cs
- tooltip.cs
- OleStrCAMarshaler.cs
- TypeTypeConverter.cs
- FieldTemplateUserControl.cs
- ListControlConvertEventArgs.cs
- PenThreadPool.cs
- FieldAccessException.cs
- QueryOptionExpression.cs
- pingexception.cs
- ModelPerspective.cs
- SQLStringStorage.cs
- ButtonFieldBase.cs
- base64Transforms.cs
- DesignerDataParameter.cs
- DataRowCollection.cs
- SettingsAttributes.cs
- BasicExpandProvider.cs
- DynamicRenderer.cs
- CryptoKeySecurity.cs
- GraphicsPath.cs
- NavigationService.cs
- BatchParser.cs
- RowSpanVector.cs
- EFAssociationProvider.cs
- LogicalExpr.cs
- UnsafeNativeMethodsPenimc.cs
- XmlnsDefinitionAttribute.cs
- OracleConnection.cs
- SafeProcessHandle.cs
- HTMLTextWriter.cs
- ScalarOps.cs
- TabControlCancelEvent.cs
- SpeakCompletedEventArgs.cs
- TransactionInterop.cs
- Token.cs
- TransportReplyChannelAcceptor.cs
- columnmapfactory.cs
- SubstitutionDesigner.cs
- StreamHelper.cs
- OverflowException.cs
- securitycriticaldataformultiplegetandset.cs
- ClientTargetCollection.cs
- contentDescriptor.cs
- Transform.cs
- DbConnectionClosed.cs
- SystemKeyConverter.cs
- SerialStream.cs
- SQLDateTime.cs
- JoinQueryOperator.cs
- HttpHeaderCollection.cs
- Inline.cs
- SamlAttributeStatement.cs
- ProcessModule.cs
- StateMachineSubscriptionManager.cs
- Collection.cs
- DnsPermission.cs
- ResourcePermissionBase.cs
- CodeDomConfigurationHandler.cs
- WebDisplayNameAttribute.cs
- DashStyle.cs
- CodeMemberProperty.cs
- StructuralType.cs
- VScrollProperties.cs
- StrokeNodeEnumerator.cs
- GeneralTransform3D.cs
- PartManifestEntry.cs
- QueryReaderSettings.cs
- Gdiplus.cs
- HtmlElementEventArgs.cs
- TextureBrush.cs
- ChannelTraceRecord.cs
- MasterPageParser.cs
- DesignerForm.cs
- StringBuilder.cs
- AttributeExtensions.cs
- ImageButton.cs
- ToolStripContentPanelDesigner.cs