Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / SqlClient / SqlReferenceCollection.cs / 1305376 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- NullableConverter.cs
- WebException.cs
- FontStretch.cs
- WebConfigurationHost.cs
- ArrayList.cs
- HwndSourceKeyboardInputSite.cs
- MultipleViewProviderWrapper.cs
- EdgeModeValidation.cs
- CroppedBitmap.cs
- PeerCustomResolverElement.cs
- ExtentJoinTreeNode.cs
- DataGridParentRows.cs
- InvalidEnumArgumentException.cs
- ExpressionDumper.cs
- SchemaImporterExtensionElement.cs
- WebBrowsableAttribute.cs
- ParagraphVisual.cs
- DbFunctionCommandTree.cs
- SurrogateChar.cs
- OdbcHandle.cs
- FileLevelControlBuilderAttribute.cs
- XmlnsDictionary.cs
- TokenBasedSet.cs
- QilIterator.cs
- LayoutExceptionEventArgs.cs
- BeginStoryboard.cs
- ToolBarButtonDesigner.cs
- ClonableStack.cs
- SizeConverter.cs
- NumericExpr.cs
- Setter.cs
- CacheEntry.cs
- PropertyDescriptorComparer.cs
- RelationshipEnd.cs
- MulticastNotSupportedException.cs
- Int32KeyFrameCollection.cs
- DependencyObjectPropertyDescriptor.cs
- SystemException.cs
- ConfigurationSectionCollection.cs
- MailDefinitionBodyFileNameEditor.cs
- EmptyControlCollection.cs
- SamlAssertionKeyIdentifierClause.cs
- UnmanagedMarshal.cs
- TextChange.cs
- AutomationPeer.cs
- EventDriven.cs
- Win32.cs
- FontClient.cs
- PersistenceMetadataNamespace.cs
- DbConnectionPoolGroupProviderInfo.cs
- Comparer.cs
- Executor.cs
- TableColumnCollectionInternal.cs
- IChannel.cs
- WinInet.cs
- messageonlyhwndwrapper.cs
- _AutoWebProxyScriptEngine.cs
- CaseInsensitiveHashCodeProvider.cs
- UnsafeNativeMethods.cs
- Int16Storage.cs
- NonPrimarySelectionGlyph.cs
- TraceSection.cs
- CoreChannel.cs
- Section.cs
- MarkupCompiler.cs
- MarkupProperty.cs
- PostBackOptions.cs
- DataGridTable.cs
- XmlDsigSep2000.cs
- DbConnectionInternal.cs
- CharAnimationUsingKeyFrames.cs
- MaskDesignerDialog.cs
- ExitEventArgs.cs
- XmlSchemas.cs
- UTF7Encoding.cs
- VirtualDirectoryMapping.cs
- XmlTextWriter.cs
- URLAttribute.cs
- NameValuePair.cs
- TraceUtils.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- sqlpipe.cs
- RIPEMD160Managed.cs
- FileClassifier.cs
- Buffer.cs
- TemplateBuilder.cs
- XamlTreeBuilderBamlRecordWriter.cs
- SqlTriggerContext.cs
- DesignerSerializationVisibilityAttribute.cs
- DispatcherProcessingDisabled.cs
- ValidatorCompatibilityHelper.cs
- TypedDataSourceCodeGenerator.cs
- XamlSerializationHelper.cs
- ImageAutomationPeer.cs
- TextParaClient.cs
- CaseStatement.cs
- CmsUtils.cs
- FamilyMapCollection.cs
- ColumnTypeConverter.cs
- Guid.cs