Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- sqlser.cs
- NullableConverter.cs
- PKCS1MaskGenerationMethod.cs
- NavigationPropertyEmitter.cs
- StreamWithDictionary.cs
- TTSVoice.cs
- TextEditorCharacters.cs
- PenThread.cs
- PerspectiveCamera.cs
- _Rfc2616CacheValidators.cs
- LowerCaseStringConverter.cs
- FormatConvertedBitmap.cs
- BigIntegerStorage.cs
- DocumentPageHost.cs
- DebuggerAttributes.cs
- TransformerInfoCollection.cs
- EventLogConfiguration.cs
- FlowDocumentPage.cs
- ContactManager.cs
- CfgParser.cs
- DelegateArgumentValue.cs
- SerializableAuthorizationContext.cs
- ResourceSet.cs
- SpanIndex.cs
- UnsafeCollabNativeMethods.cs
- HandlerBase.cs
- CqlLexerHelpers.cs
- Matrix3DStack.cs
- ImageMapEventArgs.cs
- TypeLoadException.cs
- SectionRecord.cs
- ParentUndoUnit.cs
- OutputCacheSettingsSection.cs
- ComplexPropertyEntry.cs
- RecognizedWordUnit.cs
- AnimatedTypeHelpers.cs
- IisNotInstalledException.cs
- ValidationPropertyAttribute.cs
- XmlEncoding.cs
- CurrentChangedEventManager.cs
- CollaborationHelperFunctions.cs
- ServiceMetadataBehavior.cs
- CustomError.cs
- LayoutTable.cs
- TextEditorThreadLocalStore.cs
- HttpConfigurationSystem.cs
- ModifiableIteratorCollection.cs
- ListSourceHelper.cs
- FtpWebRequest.cs
- ConfigurationManagerHelperFactory.cs
- BezierSegment.cs
- SoapCodeExporter.cs
- _Rfc2616CacheValidators.cs
- StringReader.cs
- SmiContextFactory.cs
- ReceiveContext.cs
- EntityDataSourceReferenceGroup.cs
- CurrentTimeZone.cs
- UdpRetransmissionSettings.cs
- TypeContext.cs
- BrushConverter.cs
- WindowsGraphicsCacheManager.cs
- FamilyMapCollection.cs
- WebResponse.cs
- UnlockCardRequest.cs
- AdapterDictionary.cs
- httpapplicationstate.cs
- AliasedSlot.cs
- SingleObjectCollection.cs
- DesignerSerializationVisibilityAttribute.cs
- DBSchemaRow.cs
- XmlExpressionDumper.cs
- FixedHyperLink.cs
- PeerPresenceInfo.cs
- RemotingConfigParser.cs
- ParagraphVisual.cs
- X509Chain.cs
- AddInAdapter.cs
- PointAnimationBase.cs
- TextCompositionManager.cs
- SafeRightsManagementPubHandle.cs
- SuppressIldasmAttribute.cs
- ScriptServiceAttribute.cs
- CustomErrorCollection.cs
- RtfToXamlLexer.cs
- Graphics.cs
- CounterSetInstanceCounterDataSet.cs
- ChannelServices.cs
- HitTestWithPointDrawingContextWalker.cs
- FixedSOMElement.cs
- WebPartEditorOkVerb.cs
- PasswordTextContainer.cs
- NotSupportedException.cs
- EDesignUtil.cs
- FontSource.cs
- UInt32Storage.cs
- UIPropertyMetadata.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- SqlCacheDependencyDatabaseCollection.cs
- ExceptionHandlerDesigner.cs