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
- PerformanceCounterPermissionAttribute.cs
- InternalBufferOverflowException.cs
- AutoCompleteStringCollection.cs
- GridViewEditEventArgs.cs
- SchemaImporter.cs
- PositiveTimeSpanValidatorAttribute.cs
- Figure.cs
- RegexCapture.cs
- EventSetter.cs
- Query.cs
- SimpleApplicationHost.cs
- CaseKeyBox.xaml.cs
- StringFreezingAttribute.cs
- PageBreakRecord.cs
- CompiledXpathExpr.cs
- QuaternionRotation3D.cs
- URLIdentityPermission.cs
- SqlConnectionFactory.cs
- AdjustableArrowCap.cs
- EventLogInformation.cs
- UiaCoreTypesApi.cs
- StringResourceManager.cs
- AffineTransform3D.cs
- HostingPreferredMapPath.cs
- BaseDataList.cs
- ZipIOLocalFileHeader.cs
- HttpCookie.cs
- OuterGlowBitmapEffect.cs
- SystemFonts.cs
- ConfigurationErrorsException.cs
- CorrelationRequestContext.cs
- TrackingLocationCollection.cs
- ColorConverter.cs
- Attachment.cs
- ProfileEventArgs.cs
- dbdatarecord.cs
- RightsManagementEncryptionTransform.cs
- BasicAsyncResult.cs
- SystemIPInterfaceProperties.cs
- HealthMonitoringSection.cs
- Calendar.cs
- ModifierKeysValueSerializer.cs
- JsonReader.cs
- TextParagraphView.cs
- ClientBuildManager.cs
- AuthenticateEventArgs.cs
- GridItemPattern.cs
- WebPartVerbsEventArgs.cs
- UDPClient.cs
- Evaluator.cs
- LinqMaximalSubtreeNominator.cs
- RightsManagementEncryptionTransform.cs
- ObjectStorage.cs
- XamlWriter.cs
- ContractMapping.cs
- WindowsFormsLinkLabel.cs
- FormatterServicesNoSerializableCheck.cs
- CompilerGeneratedAttribute.cs
- Fx.cs
- SwitchLevelAttribute.cs
- ResolveDuplexAsyncResult.cs
- TextHintingModeValidation.cs
- ObjectQueryProvider.cs
- Splitter.cs
- TextTreeTextNode.cs
- XPathItem.cs
- RolePrincipal.cs
- Error.cs
- namescope.cs
- MatrixValueSerializer.cs
- PathGeometry.cs
- TransferRequestHandler.cs
- IISUnsafeMethods.cs
- CultureTable.cs
- AuthenticationSection.cs
- SqlNotificationEventArgs.cs
- EntityDataSourceContextCreatingEventArgs.cs
- ColorConvertedBitmap.cs
- QueryExpr.cs
- Paragraph.cs
- CrossSiteScriptingValidation.cs
- BackStopAuthenticationModule.cs
- CmsInterop.cs
- CallTemplateAction.cs
- CodeAttributeDeclarationCollection.cs
- XmlSortKey.cs
- ObjectParameterCollection.cs
- DriveInfo.cs
- TypedElement.cs
- MeshGeometry3D.cs
- IRCollection.cs
- FileChangesMonitor.cs
- DecoderReplacementFallback.cs
- HttpServerUtilityWrapper.cs
- GroupDescription.cs
- Action.cs
- SecurityResources.cs
- UserNameSecurityTokenAuthenticator.cs
- UnaryOperationBinder.cs
- JournalEntryListConverter.cs