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
- HtmlTableCell.cs
- Point3DCollectionConverter.cs
- IPHostEntry.cs
- ValidationRuleCollection.cs
- DefinitionUpdate.cs
- BuildProvider.cs
- ShapingEngine.cs
- TextEndOfSegment.cs
- UrlMappingsModule.cs
- ResXDataNode.cs
- BindingMemberInfo.cs
- StylusButton.cs
- Table.cs
- TableChangeProcessor.cs
- InfiniteIntConverter.cs
- HttpSysSettings.cs
- TemplatePropertyEntry.cs
- SecurityChannelFactory.cs
- ImmutableAssemblyCacheEntry.cs
- DataServiceRequestOfT.cs
- DataDocumentXPathNavigator.cs
- Operators.cs
- StrokeNodeOperations.cs
- ListBase.cs
- ExpressionEditorAttribute.cs
- ContractHandle.cs
- TextReader.cs
- HwndProxyElementProvider.cs
- BounceEase.cs
- DataServiceStreamResponse.cs
- ToolBarButtonDesigner.cs
- FreezableOperations.cs
- DataStorage.cs
- XsdCachingReader.cs
- EventProxy.cs
- ModulesEntry.cs
- PrintEvent.cs
- DefaultMergeHelper.cs
- SequenceDesignerAccessibleObject.cs
- SqlDeflator.cs
- RoutedEventArgs.cs
- PageStatePersister.cs
- ValueType.cs
- AttributeQuery.cs
- ModelItem.cs
- LocalizabilityAttribute.cs
- FileLogRecordStream.cs
- TemplateKeyConverter.cs
- CallbackValidator.cs
- CodeCompileUnit.cs
- VisualBasicSettingsHandler.cs
- CodeGroup.cs
- ActivitySurrogate.cs
- Pkcs7Recipient.cs
- AppSettingsExpressionBuilder.cs
- LateBoundBitmapDecoder.cs
- ProcessHostConfigUtils.cs
- CompilationUtil.cs
- UIElementCollection.cs
- MetadataItemCollectionFactory.cs
- SqlConnectionPoolProviderInfo.cs
- FlagPanel.cs
- PageVisual.cs
- _UriTypeConverter.cs
- ChangeInterceptorAttribute.cs
- DiagnosticsConfigurationHandler.cs
- ReadOnlyHierarchicalDataSource.cs
- Utils.cs
- ListBox.cs
- CqlQuery.cs
- SqlParameter.cs
- Model3D.cs
- ViewRendering.cs
- IteratorFilter.cs
- RefreshEventArgs.cs
- LZCodec.cs
- HostExecutionContextManager.cs
- OptimizerPatterns.cs
- CodePageEncoding.cs
- LayoutEngine.cs
- IsolatedStorageFile.cs
- XmlAttributeProperties.cs
- XmlSchemaValidator.cs
- TextMarkerSource.cs
- UnionCodeGroup.cs
- ExpanderAutomationPeer.cs
- EntityParameterCollection.cs
- SecurityIdentifierElement.cs
- SHA512Managed.cs
- WebPartConnectionsCancelVerb.cs
- CryptoHelper.cs
- TemplatedControlDesigner.cs
- XhtmlTextWriter.cs
- OutputWindow.cs
- ConcurrencyMode.cs
- ByteStorage.cs
- ActivationArguments.cs
- Win32MouseDevice.cs
- CallbackException.cs
- CleanUpVirtualizedItemEventArgs.cs