Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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. // //[....] //[....] //----------------------------------------------------------------------------- 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
- PathStreamGeometryContext.cs
- FacetValues.cs
- QueueException.cs
- TemplateControlParser.cs
- TemplateControl.cs
- CommandSet.cs
- Transform3DGroup.cs
- ArrayList.cs
- XmlArrayAttribute.cs
- Selector.cs
- ProofTokenCryptoHandle.cs
- SafePEFileHandle.cs
- Propagator.cs
- Rect3D.cs
- List.cs
- WmpBitmapDecoder.cs
- ISFTagAndGuidCache.cs
- QueryableFilterUserControl.cs
- VirtualDirectoryMapping.cs
- SoapInteropTypes.cs
- AccessibleObject.cs
- XPathMultyIterator.cs
- DataGridViewTextBoxColumn.cs
- _BasicClient.cs
- RichTextBox.cs
- DbDeleteCommandTree.cs
- DecoderFallback.cs
- Method.cs
- DataControlFieldHeaderCell.cs
- CopyAction.cs
- DataServiceResponse.cs
- XmlSerializerAssemblyAttribute.cs
- ResizeGrip.cs
- Point.cs
- SessionStateContainer.cs
- SessionIDManager.cs
- PointHitTestResult.cs
- AppliedDeviceFiltersDialog.cs
- ProcessHost.cs
- HostingEnvironmentException.cs
- MissingMemberException.cs
- WebRequestModuleElementCollection.cs
- SettingsPropertyValue.cs
- IPipelineRuntime.cs
- VirtualPath.cs
- TableLayoutStyle.cs
- IsolatedStorageFile.cs
- StaticContext.cs
- PcmConverter.cs
- PackagePartCollection.cs
- TabControl.cs
- Win32Exception.cs
- JoinQueryOperator.cs
- RoutedCommand.cs
- MouseEventArgs.cs
- TextServicesLoader.cs
- HtmlInputButton.cs
- ProxyHelper.cs
- SmtpFailedRecipientsException.cs
- StringPropertyBuilder.cs
- ContentOperations.cs
- SqlClientMetaDataCollectionNames.cs
- FormatterServices.cs
- UnknownBitmapDecoder.cs
- MemberAssignmentAnalysis.cs
- DES.cs
- HttpPostedFile.cs
- XamlStream.cs
- MarkupProperty.cs
- LoginCancelEventArgs.cs
- DecoratedNameAttribute.cs
- __FastResourceComparer.cs
- FileDataSourceCache.cs
- BitmapCache.cs
- TextOnlyOutput.cs
- ServiceHostFactory.cs
- MsmqNonTransactedPoisonHandler.cs
- SocketAddress.cs
- XsdDuration.cs
- Array.cs
- BinaryConverter.cs
- Point.cs
- TypeConverterMarkupExtension.cs
- SiteOfOriginContainer.cs
- XmlDictionaryString.cs
- HtmlAnchor.cs
- WpfWebRequestHelper.cs
- CroppedBitmap.cs
- Context.cs
- ListViewInsertedEventArgs.cs
- OracleEncoding.cs
- VerificationAttribute.cs
- NonBatchDirectoryCompiler.cs
- Menu.cs
- ZipIOCentralDirectoryFileHeader.cs
- ProcessModelSection.cs
- ProgressBarRenderer.cs
- TextClipboardData.cs
- BindingExpression.cs
- XamlBuildProvider.cs