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
- CodeTypeDeclarationCollection.cs
- xmlsaver.cs
- NullableIntMinMaxAggregationOperator.cs
- Icon.cs
- LocatorGroup.cs
- HtmlInputFile.cs
- KerberosRequestorSecurityToken.cs
- PositiveTimeSpanValidatorAttribute.cs
- WasHttpHandlersInstallComponent.cs
- XmlSchemaAnyAttribute.cs
- AppDomainProtocolHandler.cs
- ClientProxyGenerator.cs
- DataGridViewCellEventArgs.cs
- ToolTip.cs
- ExtendedPropertyInfo.cs
- CollectionMarkupSerializer.cs
- XmlRawWriterWrapper.cs
- MarkupObject.cs
- RawStylusInputCustomDataList.cs
- UserControlFileEditor.cs
- SqlDataSourceCommandEventArgs.cs
- BuiltInPermissionSets.cs
- Span.cs
- DataBindingExpressionBuilder.cs
- NonSerializedAttribute.cs
- EdmProperty.cs
- DecimalSumAggregationOperator.cs
- PersonalizationEntry.cs
- XsltInput.cs
- AbstractDataSvcMapFileLoader.cs
- PlainXmlSerializer.cs
- SemanticKeyElement.cs
- XmlUtil.cs
- SqlUserDefinedTypeAttribute.cs
- ObjectIDGenerator.cs
- BuildManager.cs
- _NestedSingleAsyncResult.cs
- EventLog.cs
- TextClipboardData.cs
- StringResourceManager.cs
- GB18030Encoding.cs
- Propagator.Evaluator.cs
- ModelVisual3D.cs
- DockAndAnchorLayout.cs
- GC.cs
- MultiPropertyDescriptorGridEntry.cs
- ShaderEffect.cs
- InvalidDataContractException.cs
- TreeSet.cs
- SerializationFieldInfo.cs
- AmbientProperties.cs
- RequestQueryParser.cs
- CatalogZone.cs
- PolyLineSegment.cs
- CodeParameterDeclarationExpressionCollection.cs
- ConfigXmlWhitespace.cs
- BrowserDefinition.cs
- NativeRecognizer.cs
- ConnectionAcceptor.cs
- SqlBulkCopyColumnMappingCollection.cs
- ConditionCollection.cs
- CollectionDataContract.cs
- IsolatedStorageFileStream.cs
- ListViewItem.cs
- CorrelationHandle.cs
- MultilineStringConverter.cs
- XPathNodeInfoAtom.cs
- EdmSchemaError.cs
- WizardPanelChangingEventArgs.cs
- ImageDrawing.cs
- Profiler.cs
- ManagementBaseObject.cs
- EditorZoneBase.cs
- XmlIterators.cs
- PerformanceCounterManager.cs
- CreateUserWizardStep.cs
- TripleDES.cs
- PenCursorManager.cs
- ItemList.cs
- RepeatInfo.cs
- MinimizableAttributeTypeConverter.cs
- XamlFxTrace.cs
- DefaultPropertiesToSend.cs
- CFGGrammar.cs
- Bold.cs
- ModelService.cs
- EntityTransaction.cs
- IsolatedStoragePermission.cs
- WindowsStreamSecurityBindingElement.cs
- SafeNativeMethodsMilCoreApi.cs
- DrawingContext.cs
- GestureRecognizer.cs
- DataContext.cs
- SQLGuidStorage.cs
- Win32NamedPipes.cs
- FontWeightConverter.cs
- AccessDataSource.cs
- ErrorTolerantObjectWriter.cs
- SamlNameIdentifierClaimResource.cs
- HwndSourceParameters.cs