Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- TextBoxDesigner.cs
- FileDialog_Vista_Interop.cs
- InstanceCollisionException.cs
- JsonQNameDataContract.cs
- _SslSessionsCache.cs
- BindingExpressionBase.cs
- ExtendedPropertyDescriptor.cs
- ZipIORawDataFileBlock.cs
- AspCompat.cs
- PathTooLongException.cs
- QilStrConcatenator.cs
- ReferenceConverter.cs
- ToolboxItemAttribute.cs
- AttributeEmitter.cs
- ReflectionTypeLoadException.cs
- ContentType.cs
- SymLanguageType.cs
- DataMemberAttribute.cs
- JavaScriptObjectDeserializer.cs
- Registry.cs
- InProcStateClientManager.cs
- X509Certificate2.cs
- ArrayList.cs
- TimelineCollection.cs
- KeyConverter.cs
- HttpRuntime.cs
- ConfigXmlComment.cs
- CollectionBase.cs
- FixedHighlight.cs
- XmlSchemaAnnotation.cs
- IOException.cs
- GridViewDeletedEventArgs.cs
- FormatConvertedBitmap.cs
- HtmlWindowCollection.cs
- DataViewListener.cs
- ThreadInterruptedException.cs
- InProcStateClientManager.cs
- ContractValidationHelper.cs
- PrimaryKeyTypeConverter.cs
- ActionMessageFilterTable.cs
- TextEditorSpelling.cs
- ClientProxyGenerator.cs
- ReadOnlyPropertyMetadata.cs
- DockAndAnchorLayout.cs
- UrlMapping.cs
- WebPermission.cs
- XmlNamedNodeMap.cs
- sqlpipe.cs
- RuntimeIdentifierPropertyAttribute.cs
- AsymmetricKeyExchangeFormatter.cs
- SetterBaseCollection.cs
- CustomAttributeSerializer.cs
- ObjectDataSource.cs
- DefaultHttpHandler.cs
- TreeViewHitTestInfo.cs
- CollectionContainer.cs
- DecoratedNameAttribute.cs
- DataSourceControlBuilder.cs
- Types.cs
- EntityDataSourceEntitySetNameItem.cs
- ConfigUtil.cs
- PenThreadWorker.cs
- InputLangChangeRequestEvent.cs
- BaseResourcesBuildProvider.cs
- documentsequencetextpointer.cs
- _NetRes.cs
- StringTraceRecord.cs
- BaseTreeIterator.cs
- HierarchicalDataSourceControl.cs
- AssemblyInfo.cs
- _FtpDataStream.cs
- NetMsmqBinding.cs
- FlowDocument.cs
- SoapExtensionStream.cs
- CheckStoreFileValidityRequest.cs
- SpecialTypeDataContract.cs
- WebEncodingValidator.cs
- Ipv6Element.cs
- WindowsTitleBar.cs
- AppSettingsExpressionEditor.cs
- LazyTextWriterCreator.cs
- XmlTextReaderImplHelpers.cs
- AuthenticationModuleElementCollection.cs
- XmlILIndex.cs
- ConcurrentQueue.cs
- ObjectQueryProvider.cs
- VolatileEnlistmentState.cs
- HtmlTableRow.cs
- RectangleHotSpot.cs
- RegexMatchCollection.cs
- ProcessMonitor.cs
- AssertSection.cs
- MobileErrorInfo.cs
- WinInet.cs
- XMLDiffLoader.cs
- ObjectDataSourceSelectingEventArgs.cs
- ManipulationInertiaStartingEventArgs.cs
- Enlistment.cs
- NativeWindow.cs
- SapiInterop.cs