Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PageThemeCodeDomTreeGenerator.cs
- LocalizabilityAttribute.cs
- Page.cs
- MessageSecurityException.cs
- IISMapPath.cs
- COM2PropertyDescriptor.cs
- ClusterSafeNativeMethods.cs
- TextDecorationCollection.cs
- safelink.cs
- ContextProperty.cs
- _AutoWebProxyScriptEngine.cs
- PassportAuthenticationModule.cs
- StylusPlugInCollection.cs
- HostDesigntimeLicenseContext.cs
- XamlBrushSerializer.cs
- HtmlWindowCollection.cs
- BufferBuilder.cs
- SerializableTypeCodeDomSerializer.cs
- CheckBoxBaseAdapter.cs
- CollectionChangeEventArgs.cs
- RouteParametersHelper.cs
- TextDecoration.cs
- OdbcDataReader.cs
- DataControlFieldHeaderCell.cs
- DateTimeFormat.cs
- XPathCompileException.cs
- GCHandleCookieTable.cs
- AppliedDeviceFiltersEditor.cs
- MouseWheelEventArgs.cs
- ObjectReaderCompiler.cs
- _HTTPDateParse.cs
- sqlnorm.cs
- InputScopeManager.cs
- RayHitTestParameters.cs
- WindowsFormsHost.cs
- DbSetClause.cs
- NavigationExpr.cs
- _emptywebproxy.cs
- MemoryStream.cs
- UIElementPropertyUndoUnit.cs
- DependencyPropertyKind.cs
- PropertyManager.cs
- XmlTextReaderImplHelpers.cs
- ActivityMarkupSerializationProvider.cs
- CodeIdentifier.cs
- RecognizerBase.cs
- EventBuilder.cs
- HttpCacheVary.cs
- ThemeInfoAttribute.cs
- Button.cs
- ScopedKnownTypes.cs
- Subtree.cs
- sqlpipe.cs
- Stylesheet.cs
- Misc.cs
- compensatingcollection.cs
- DataSvcMapFile.cs
- Setter.cs
- ProviderConnectionPoint.cs
- InstanceStore.cs
- Mapping.cs
- InvalidOleVariantTypeException.cs
- DocumentOrderComparer.cs
- CharAnimationUsingKeyFrames.cs
- ClientApiGenerator.cs
- GridViewSortEventArgs.cs
- Matrix.cs
- ProviderBase.cs
- RefType.cs
- HyperLinkColumn.cs
- DateRangeEvent.cs
- Part.cs
- Stack.cs
- ApplicationActivator.cs
- WizardPanel.cs
- PerfCounters.cs
- CompilationRelaxations.cs
- PathStreamGeometryContext.cs
- PermissionToken.cs
- KeyedCollection.cs
- TextSelection.cs
- ScriptingSectionGroup.cs
- CounterSample.cs
- Environment.cs
- NavigationProperty.cs
- SpellerInterop.cs
- SHA384.cs
- SmtpMail.cs
- SingleConverter.cs
- DataColumnSelectionConverter.cs
- IIS7WorkerRequest.cs
- IndentTextWriter.cs
- SQLGuidStorage.cs
- streamingZipPartStream.cs
- Error.cs
- PolicyChain.cs
- Int64AnimationBase.cs
- DataGridViewRowPostPaintEventArgs.cs
- AutomationProperties.cs
- CodeGenerator.cs