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
- Vector3dCollection.cs
- _HTTPDateParse.cs
- SqlBulkCopyColumnMappingCollection.cs
- IdentityManager.cs
- TemplateControlParser.cs
- DynamicQueryableWrapper.cs
- MouseDevice.cs
- XmlAutoDetectWriter.cs
- ScriptReferenceEventArgs.cs
- ParallelTimeline.cs
- MissingFieldException.cs
- ObjectDataSourceStatusEventArgs.cs
- WorkflowTraceTransfer.cs
- HtmlHead.cs
- DiscardableAttribute.cs
- PeerApplicationLaunchInfo.cs
- InputScopeConverter.cs
- ContentPropertyAttribute.cs
- FixedSOMContainer.cs
- DataSourceView.cs
- ProtocolElement.cs
- InternalConfigConfigurationFactory.cs
- ChangesetResponse.cs
- XmlDataSourceNodeDescriptor.cs
- SmiEventSink_DeferedProcessing.cs
- DocumentPaginator.cs
- DbParameterHelper.cs
- OleDbTransaction.cs
- FontFamilyIdentifier.cs
- BulletedList.cs
- Span.cs
- CodeLinePragma.cs
- RSACryptoServiceProvider.cs
- HtmlMeta.cs
- WindowsSpinner.cs
- MailHeaderInfo.cs
- WebPart.cs
- ListItemCollection.cs
- RadioButtonPopupAdapter.cs
- FastEncoder.cs
- LambdaCompiler.Binary.cs
- SQLBinary.cs
- recordstate.cs
- Catch.cs
- EntityDataReader.cs
- SmiEventSink_DeferedProcessing.cs
- XmlSchemaGroup.cs
- StringArrayConverter.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- OutputCacheSection.cs
- SafeFindHandle.cs
- GetTokenRequest.cs
- GridViewCellAutomationPeer.cs
- DynamicField.cs
- TableLayoutRowStyleCollection.cs
- IntranetCredentialPolicy.cs
- RuleValidation.cs
- PerfCounterSection.cs
- ClientConfigurationSystem.cs
- HtmlTableRow.cs
- FloaterParaClient.cs
- StylusPlugin.cs
- TextSerializer.cs
- MsmqIntegrationInputMessage.cs
- ListenerElementsCollection.cs
- EventMappingSettings.cs
- WorkflowRuntimeServiceElement.cs
- CngKeyBlobFormat.cs
- ResourceSet.cs
- EntityViewGenerationConstants.cs
- ParseNumbers.cs
- EditingCommands.cs
- Partitioner.cs
- CFGGrammar.cs
- DefaultEventAttribute.cs
- TableCell.cs
- IntSecurity.cs
- PropertyRecord.cs
- PathParser.cs
- ScriptRef.cs
- DataBoundControl.cs
- SettingsAttributes.cs
- TextRangeEditTables.cs
- TextTrailingWordEllipsis.cs
- BinaryFormatter.cs
- PrimitiveSchema.cs
- TraceContextEventArgs.cs
- PropertyGridEditorPart.cs
- XamlRtfConverter.cs
- DataGridViewEditingControlShowingEventArgs.cs
- IdentityReference.cs
- ProgressBarBrushConverter.cs
- MemberMaps.cs
- HtmlTernaryTree.cs
- ClientTarget.cs
- CroppedBitmap.cs
- StringOutput.cs
- XmlSchemaDocumentation.cs
- ConnectionStringSettings.cs
- SqlReorderer.cs