Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LifetimeServices.cs
- LinkGrep.cs
- XmlSchemaImport.cs
- HttpHandlersSection.cs
- TreeView.cs
- RootAction.cs
- RequestQueryProcessor.cs
- KeyConverter.cs
- SynchronizationLockException.cs
- XmlDocument.cs
- PersonalizationStateInfoCollection.cs
- InvokeProviderWrapper.cs
- DocumentCollection.cs
- XmlHelper.cs
- XmlAttributes.cs
- DynamicObject.cs
- AlgoModule.cs
- XmlAnyElementAttributes.cs
- TextRange.cs
- coordinator.cs
- InstanceData.cs
- HasCopySemanticsAttribute.cs
- ViewCellSlot.cs
- XmlCollation.cs
- MethodSet.cs
- WorkflowDefinitionDispenser.cs
- Utils.cs
- ConstraintCollection.cs
- DivideByZeroException.cs
- ExceptionNotification.cs
- AsymmetricKeyExchangeFormatter.cs
- ListControl.cs
- DesignerActionUIStateChangeEventArgs.cs
- ControlBuilderAttribute.cs
- DataGridViewColumnStateChangedEventArgs.cs
- CacheMode.cs
- RawStylusInputCustomData.cs
- AliasExpr.cs
- VScrollBar.cs
- SettingsPropertyCollection.cs
- ClrProviderManifest.cs
- ColorContext.cs
- KeyConstraint.cs
- HttpApplication.cs
- DBSqlParserTableCollection.cs
- Vector3D.cs
- TcpActivation.cs
- OrderPreservingPipeliningSpoolingTask.cs
- PtsPage.cs
- CodeChecksumPragma.cs
- ZipQueryOperator.cs
- CodeTypeReferenceCollection.cs
- ZoneButton.cs
- Pkcs9Attribute.cs
- WinFormsSpinner.cs
- GridViewRowPresenterBase.cs
- ILGenerator.cs
- CollectionViewGroup.cs
- ClickablePoint.cs
- HttpRequest.cs
- SizeChangedInfo.cs
- WindowsListBox.cs
- ConfigXmlText.cs
- EntityModelBuildProvider.cs
- ParameterBuilder.cs
- StreamAsIStream.cs
- Int16.cs
- JavaScriptString.cs
- PrePrepareMethodAttribute.cs
- SafeNativeMethods.cs
- DbUpdateCommandTree.cs
- ParserExtension.cs
- Delegate.cs
- ServicePoint.cs
- SchemaTypeEmitter.cs
- ResourceAttributes.cs
- EntityDescriptor.cs
- CompensationDesigner.cs
- XmlIgnoreAttribute.cs
- ContextStack.cs
- CompositeClientFormatter.cs
- ApplicationInfo.cs
- DataIdProcessor.cs
- DeviceContext2.cs
- XmlSchemaObjectTable.cs
- Codec.cs
- ExtenderProviderService.cs
- PointValueSerializer.cs
- PeerNameRecordCollection.cs
- cookie.cs
- Object.cs
- TemplateBindingExtensionConverter.cs
- SolidBrush.cs
- SafeLibraryHandle.cs
- IDictionary.cs
- InstanceDescriptor.cs
- CDSsyncETWBCLProvider.cs
- FrameAutomationPeer.cs
- _NetRes.cs
- PolyQuadraticBezierSegmentFigureLogic.cs