Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ValidationErrorCollection.cs
- CodeNamespace.cs
- ValidatedControlConverter.cs
- CodePrimitiveExpression.cs
- Automation.cs
- HttpWebResponse.cs
- InstanceDataCollection.cs
- DetailsViewInsertedEventArgs.cs
- MetadataPropertyvalue.cs
- SyntaxCheck.cs
- MetadataSerializer.cs
- URL.cs
- PrivilegedConfigurationManager.cs
- SoapElementAttribute.cs
- BamlLocalizableResourceKey.cs
- Utils.cs
- GradientBrush.cs
- DoubleUtil.cs
- OpenTypeMethods.cs
- PageBreakRecord.cs
- SessionStateUtil.cs
- FaultReason.cs
- SimpleParser.cs
- XmlLinkedNode.cs
- ContentIterators.cs
- HMACSHA256.cs
- PolyBezierSegment.cs
- SafeCryptContextHandle.cs
- SqlMethodAttribute.cs
- MimeWriter.cs
- HttpProxyTransportBindingElement.cs
- SqlFunctions.cs
- Transform3D.cs
- DrawingState.cs
- AuthenticationService.cs
- XmlAnyElementAttribute.cs
- TextServicesHost.cs
- SelectorAutomationPeer.cs
- SelectionRange.cs
- EncryptedReference.cs
- TextTreeNode.cs
- Base64WriteStateInfo.cs
- DataGrid.cs
- NegatedConstant.cs
- Ref.cs
- DesignerAutoFormatStyle.cs
- TypeDescriptorContext.cs
- PipelineModuleStepContainer.cs
- XmlAggregates.cs
- HelpProvider.cs
- Converter.cs
- SourceChangedEventArgs.cs
- ObjectRef.cs
- ExceptionHandlers.cs
- InternalDispatchObject.cs
- CatalogPartChrome.cs
- EntityDataSourceViewSchema.cs
- VirtualizingStackPanel.cs
- DiagnosticsConfigurationHandler.cs
- brushes.cs
- TrackingDataItemValue.cs
- ConsoleKeyInfo.cs
- MediaSystem.cs
- DependencyProperty.cs
- GraphicsContainer.cs
- GetCertificateRequest.cs
- EntityDesignPluralizationHandler.cs
- FrameworkElementFactoryMarkupObject.cs
- InvokePattern.cs
- IApplicationTrustManager.cs
- HttpCapabilitiesBase.cs
- ProfileModule.cs
- XamlSerializer.cs
- ErrorWebPart.cs
- PageStatePersister.cs
- InstalledFontCollection.cs
- RadioButton.cs
- StandardBindingImporter.cs
- InternalConfigEventArgs.cs
- ConfigurationValues.cs
- SharedStatics.cs
- AttributeEmitter.cs
- CalendarTable.cs
- DataSourceCacheDurationConverter.cs
- TextDecorationCollection.cs
- WebPartDisplayModeEventArgs.cs
- Registry.cs
- ToolStripControlHost.cs
- OpenTypeMethods.cs
- BaseProcessProtocolHandler.cs
- MergeLocalizationDirectives.cs
- ProgressBarAutomationPeer.cs
- IntegerValidatorAttribute.cs
- Cursors.cs
- ListViewContainer.cs
- StyleSheetRefUrlEditor.cs
- EntityException.cs
- IncrementalCompileAnalyzer.cs
- ExtendedPropertyDescriptor.cs
- KeyPressEvent.cs