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
- EnterpriseServicesHelper.cs
- ConstraintManager.cs
- PageClientProxyGenerator.cs
- NavigationPropertyEmitter.cs
- PreloadHost.cs
- Expression.DebuggerProxy.cs
- MutexSecurity.cs
- TopClause.cs
- DataGridViewSelectedCellCollection.cs
- DiscoveryClientBindingElement.cs
- Hashtable.cs
- DataGridViewCellPaintingEventArgs.cs
- NativeRecognizer.cs
- EntityContainerEmitter.cs
- ClientEventManager.cs
- PagesChangedEventArgs.cs
- RadioButtonDesigner.cs
- XPathParser.cs
- Int16AnimationBase.cs
- DateTimePickerDesigner.cs
- FullTextLine.cs
- RuleProcessor.cs
- Assert.cs
- DeleteBookmarkScope.cs
- XmlElementElement.cs
- ItemCollection.cs
- ZipIOLocalFileDataDescriptor.cs
- OdbcConnectionPoolProviderInfo.cs
- HScrollProperties.cs
- SqlDataSourceCommandParser.cs
- ConfigXmlText.cs
- CmsInterop.cs
- PersistChildrenAttribute.cs
- RowCache.cs
- EUCJPEncoding.cs
- RSAPKCS1KeyExchangeFormatter.cs
- GeneralTransform.cs
- UInt64.cs
- ByteRangeDownloader.cs
- SingleResultAttribute.cs
- PackageFilter.cs
- TextBoxRenderer.cs
- WebPartDisplayModeCollection.cs
- ImageBrush.cs
- DataControlFieldCollection.cs
- ComponentEvent.cs
- AutomationElementCollection.cs
- DeclarativeExpressionConditionDeclaration.cs
- MULTI_QI.cs
- ConfigurationValidatorAttribute.cs
- FixedPageProcessor.cs
- SettingsProperty.cs
- ResourcesBuildProvider.cs
- DisplayMemberTemplateSelector.cs
- SoapFormatExtensions.cs
- FixedSOMContainer.cs
- AttributeProviderAttribute.cs
- SafeWaitHandle.cs
- IntersectQueryOperator.cs
- BitConverter.cs
- Compiler.cs
- IncrementalHitTester.cs
- GridErrorDlg.cs
- DeclarativeCatalogPart.cs
- SqlDataSourceQueryEditorForm.cs
- EncodingDataItem.cs
- _NestedMultipleAsyncResult.cs
- XNodeSchemaApplier.cs
- DetailsViewCommandEventArgs.cs
- Viewport3DVisual.cs
- SettingsProperty.cs
- RijndaelManaged.cs
- Query.cs
- UpdatePanelTriggerCollection.cs
- URLMembershipCondition.cs
- EditorPartChrome.cs
- TypeGeneratedEventArgs.cs
- SafeEventHandle.cs
- WebPartEditorCancelVerb.cs
- XmlQualifiedNameTest.cs
- Package.cs
- DrawingBrush.cs
- EventLogWatcher.cs
- ChannelSinkStacks.cs
- SecurityContext.cs
- SchemaTableColumn.cs
- DbConvert.cs
- StylusPlugInCollection.cs
- MaterializeFromAtom.cs
- TryCatchDesigner.xaml.cs
- AuthenticateEventArgs.cs
- ToolStripScrollButton.cs
- TypeListConverter.cs
- _FixedSizeReader.cs
- DefaultHttpHandler.cs
- AbstractDataSvcMapFileLoader.cs
- CreateUserWizard.cs
- GeneralTransform.cs
- StringArrayConverter.cs
- Currency.cs