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
- XmlObjectSerializerReadContextComplexJson.cs
- TextParagraph.cs
- OleDbError.cs
- OdbcConnectionFactory.cs
- EntityException.cs
- TrustManager.cs
- GridViewColumnCollection.cs
- SurrogateEncoder.cs
- ListCommandEventArgs.cs
- FormViewUpdatedEventArgs.cs
- UIAgentInitializationException.cs
- ParserContext.cs
- CodeAttributeDeclaration.cs
- PresentationUIStyleResources.cs
- ScriptReferenceEventArgs.cs
- BitmapEffectInput.cs
- Metadata.cs
- HybridWebProxyFinder.cs
- DateRangeEvent.cs
- ModifierKeysValueSerializer.cs
- NeutralResourcesLanguageAttribute.cs
- CopyOnWriteList.cs
- HyperLink.cs
- BmpBitmapDecoder.cs
- TdsParserHelperClasses.cs
- TraceListener.cs
- FillBehavior.cs
- GeometryValueSerializer.cs
- AttachmentService.cs
- SelectionProcessor.cs
- OperatingSystemVersionCheck.cs
- GlyphCache.cs
- ModelItemDictionaryImpl.cs
- DelegatingTypeDescriptionProvider.cs
- RadioButtonFlatAdapter.cs
- IUnknownConstantAttribute.cs
- ColumnHeaderConverter.cs
- EditorPartChrome.cs
- ProgressiveCrcCalculatingStream.cs
- StorageModelBuildProvider.cs
- Scanner.cs
- LinqDataSourceDeleteEventArgs.cs
- Drawing.cs
- XmlAttributeOverrides.cs
- SoapEnumAttribute.cs
- DeferredReference.cs
- FixedTextSelectionProcessor.cs
- DeviceContext2.cs
- FunctionQuery.cs
- SimpleBitVector32.cs
- ManagementPath.cs
- IPHostEntry.cs
- RectangleF.cs
- InstanceDataCollection.cs
- UnsafeNetInfoNativeMethods.cs
- MbpInfo.cs
- ConstructorArgumentAttribute.cs
- RenderContext.cs
- FixedSOMLineCollection.cs
- MatrixKeyFrameCollection.cs
- InputReport.cs
- SessionConnectionReader.cs
- PersonalizationAdministration.cs
- TemplateBindingExtension.cs
- FontDifferentiator.cs
- PointAnimationUsingPath.cs
- JsonQueryStringConverter.cs
- EntityDataSourceQueryBuilder.cs
- IntSecurity.cs
- ViewGenerator.cs
- StreamGeometryContext.cs
- ClockGroup.cs
- InitializationEventAttribute.cs
- WebPartEditorApplyVerb.cs
- ToolStripHighContrastRenderer.cs
- AxParameterData.cs
- OperationDescription.cs
- TypeLibConverter.cs
- SQLDateTimeStorage.cs
- CodeCastExpression.cs
- LogRestartAreaEnumerator.cs
- SystemException.cs
- HMACSHA256.cs
- DateTimeFormatInfoScanner.cs
- MenuEventArgs.cs
- AsyncResult.cs
- Point3DAnimationUsingKeyFrames.cs
- PrintPageEvent.cs
- AxisAngleRotation3D.cs
- Error.cs
- HttpWrapper.cs
- EncryptedType.cs
- ViewManager.cs
- DesignTimeType.cs
- FileDetails.cs
- ServiceModelInstallComponent.cs
- CodeParameterDeclarationExpression.cs
- XmlRootAttribute.cs
- PrimitiveXmlSerializers.cs
- WebBrowserContainer.cs