Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- StdValidatorsAndConverters.cs
- TargetControlTypeAttribute.cs
- DataGridColumnDropSeparator.cs
- SafeViewOfFileHandle.cs
- DataRow.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- WebPartVerbsEventArgs.cs
- UshortList2.cs
- DataGridAddNewRow.cs
- Size3DConverter.cs
- ScalarConstant.cs
- SQLRoleProvider.cs
- AtomContentProperty.cs
- PersistChildrenAttribute.cs
- FileReader.cs
- BaseDataListActionList.cs
- ObjectQueryExecutionPlan.cs
- LinkLabelLinkClickedEvent.cs
- QueryTreeBuilder.cs
- FlagsAttribute.cs
- DES.cs
- ImageList.cs
- ColumnHeaderCollectionEditor.cs
- EditorResources.cs
- OdbcConnectionStringbuilder.cs
- TrackingServices.cs
- EntityDataSourceDesigner.cs
- XmlDataContract.cs
- LocationSectionRecord.cs
- SwitchAttribute.cs
- ApplicationBuildProvider.cs
- HttpListenerException.cs
- FileAuthorizationModule.cs
- DBCommandBuilder.cs
- ParentUndoUnit.cs
- DynamicAttribute.cs
- ResourceManagerWrapper.cs
- COM2ExtendedUITypeEditor.cs
- MenuItemBinding.cs
- MessageContractAttribute.cs
- DesignerDataParameter.cs
- HttpWriter.cs
- DataBinder.cs
- BCLDebug.cs
- SerializationTrace.cs
- TraceInternal.cs
- RuleConditionDialog.Designer.cs
- Button.cs
- SqlMetaData.cs
- EdmValidator.cs
- TextMarkerSource.cs
- HttpRuntime.cs
- ScrollPatternIdentifiers.cs
- ZipArchive.cs
- DefaultPropertyAttribute.cs
- FamilyCollection.cs
- BindingObserver.cs
- HtmlControlPersistable.cs
- AxHost.cs
- CapabilitiesState.cs
- UshortList2.cs
- CultureTableRecord.cs
- ByeOperation11AsyncResult.cs
- CommonObjectSecurity.cs
- FileChangeNotifier.cs
- GridViewAutomationPeer.cs
- JsonWriterDelegator.cs
- ObjectTypeMapping.cs
- SerialErrors.cs
- AcceptorSessionSymmetricMessageSecurityProtocol.cs
- AddInStore.cs
- OutOfProcStateClientManager.cs
- InkCanvas.cs
- WebPartZoneCollection.cs
- BitmapFrameDecode.cs
- ToolboxItemFilterAttribute.cs
- ResourcesGenerator.cs
- InternalDispatchObject.cs
- WebControlAdapter.cs
- XmlRootAttribute.cs
- ControlParameter.cs
- DataGridViewCellFormattingEventArgs.cs
- RequestQueue.cs
- ComplexBindingPropertiesAttribute.cs
- BinaryReader.cs
- oledbmetadatacollectionnames.cs
- StringConverter.cs
- MediaCommands.cs
- WebPartDisplayModeEventArgs.cs
- QilName.cs
- SubstitutionList.cs
- SecurityChannelFaultConverter.cs
- DetailsViewUpdateEventArgs.cs
- ConfigXmlAttribute.cs
- GeometryCombineModeValidation.cs
- FileStream.cs
- UpdateManifestForBrowserApplication.cs
- EndOfStreamException.cs
- AttributeQuery.cs
- LayoutEvent.cs